Memory leak with Canvas and streaming video
See original GitHub issueUsing Chrome 16.
First, I create a texture object from a canvas that is loaded from a MJPEG stream and store it into a custom object within a function that I call every 1/3 of a second. I am constantly refreshing my canvas with a streaming video.
var ctx = canvas.getContext('2d');
ctx.drawImage(img, 0, 0);
var texture = new THREE.Texture(canvas);
streamObject.texture = texture;
Then, I execute another function to display that texture by retrieving it from the custom object and setting the material’s map to that texture before I call my render function.
vCam.material.map = textureTemp;
render(vCam);
The problem however is that my memory climbs through the roof If I do not force a garbage collection with:
try {
window.gc();
} catch(e) {
console.log("Garbage Collection is not available for this browser type.");
}
I would like to avoid forcing the garbage collection. Is it possible that the texture objects are not being gc’d creating my memory to climb?
Issue Analytics
- State:
- Created 12 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Memory Leak when Drawing Video to Canvas using ...
I found the problem was in this.canvas.captureStream() . I want to collage 1920x1080 side by side to create dual-monitor screen recorder, ...
Read more >Memory leak when switching video streams from different ...
In my web application, I have 4 camera feeds streaming from different cameras. Every few seconds, the camera feeds will change their video...
Read more >Mediarecorder used on canvas mediastream with audio track ...
Mediarecorder used on canvas mediastream with audio track results in increasing RAM usage/memory leak · Categories · Tracking · People · References ·...
Read more >Plugging Memory Leaks With The Chrome Dev Tools - Ben Dilts
Garbage collection does not protect you from memory leaks. The Chrome Dev Tools have introduced a ... Your browser can't play this video....
Read more >Memory Leak while streaming | OBS Forums
OBS (Open Broadcaster Software) is free and open source software for video recording and live streaming. Stream to Twitch, YouTube and many ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Thats wrong. You should never create new objects in a render loop. You should be able to do this inside
init().Here is a simple code which makes this problem occur… What am I doing wrong here ?