Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 140788

WebGL bufferData typed array memory leak?

$
0
0

I have a really simple function that I think is creating a memory leak in Chrome and I'm not sure how to fix. If I comment it out the leak seems to go away, but I need it in order to run my WebGL application.

The function is when I'm passing my data to a buffer, for the example I'll use the ELEMENT_ARRAY_BUFFER function:

indexBuffer(buffer, data) {
    var d = new Uint16Array(data);
    this.getContext().bindBuffer(this.getContext().ELEMENT_ARRAY_BUFFER, buffer);
    this.getContext().bufferData(this.getContext().ELEMENT_ARRAY_BUFFER, d, this.getContext().STATIC_DRAW);
}

So now if I open up the chrome performance tab and I run it for 5 minutes, over time the memory will slowly build up due to requestAnimationFrame and then drop once the GC kicks in. When the GC kicks in and it drops it doesn't drop down to the level that it started at, there's always a little bit left over and things remain this way over the entire time. So at the start the lowest level that the JS heap is at might be 3,000,000 but after 5 minutes it's built up to a point where the lowest level it'll drop to is 6,000,000.

If I change my code so it doesn't include:

new Uint16Array(data);

and I only pass in data as suggested in this thread: webgl bufferData memory leak with chrome

then the application doesn't run and I get a warning saying something along the lines of "Insufficient buffer allocation".

I'm only creating my buffer once, but I'm running indexBuffer() each frame.

If I comment out this function and I repeat this the memory leak seems to go away and the memory drops down to the lowest level each time the GC kicks in.

Is there something wrong with my code?


Viewing all articles
Browse latest Browse all 140788

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>