In a futile attempt to write perfect javascript, I deal with the Javascript heap issue. I lowered it to the lowest level I can, but I have run out of options, and I don’t understand what’s going on (well, I think this is rAF overhead, but guesses are not taken into account).
Pile of sawtooth (light blue):

The above chart is taken from a simple visualization of the canvas particles on the entire page. The goal of this exercise is to reduce the amplitude of the sawtooth heap and possibly also increase the period between cleanings.
If you look closely, the heap increases by about 15 KB every 60 seconds and drops from 3.3 MB to 2.4 MB every ~ 1 second.

What I don’t understand is the timing and amount of growth of 15K.
The heap increases by 15 KB immediately before downtime and ~ 0.015 ms after the next function returns to idle (below is my top-level function).
var renderList = []; var stop = false; var i; function update(timer) { // Main update loop if(!stop){ requestAnimationFrame(update); } for(i = 0; i < renderList.length; i ++){ renderList[i](timer,ctx, w, h); } }
Nothing I do with the code reduces or changes the location of the heap growth. The distribution profile shows that I do not allocate any memory. GC is at 0.08% in the processor profile (what does it do, I don’t know ?, does it also manage the heap?)
Can someone explain to me what this memory is used for? and how can I reduce or make the line flat?
I understand that I can not do anything, but at the moment I have no vague idea of what is put in a heap? It would be nice to know.
A snippet is just the code called from update (the code snippet above). I do not think it is appropriate, but just in case. This is the code that was executed and returned immediately before the heap growth.
var p,d,s; var renderCount = 0; var fxId = 0; var lastTime; var frameTime = 0; var minParticles = 10; var particleCount = minParticles; var frameSum = 0; var frameAve = 0; var frameWorkTime = 0; var lastFrameWorkTime = 0; var particleRenderTimeMax = 0; var m = 0; var mC = 0; var mR = 0; var then,tx,ty; var renderTime,then1;