Chrome heap snapshot

Hey guys,

I have a function that:

  • parses some JSON
  • builds some objects
  • then diffs some DOM nodes (50k for testing)

I had a memory leak that I have fixed but for some reason:

  • performance.memory() logged before and after object creation (not globals) doesn’t show an increase in heap size

  • memory -> JS heap snapshot shows an increase/ decrease in heap size in relation to how many DOM nodes are on the page after the function returns

There are no:

  • global objects (except functions);
  • event listeners (yet)
  • closures
  • timing methods
  • Dom node ID’s

So I’m wondering:

  • why are objects being pushed to stack memory and not the heap in chrome?

  • why would the “JS” heap reference DOM nodes unless they had ID’s?

This one goes way beyond my level of understanding here :stuck_out_tongue:

One thing that I remember from a long time ago. If you are creating elements, all of those created elements will have a reference in the DOM. That could be where the memory is going towards.

For stack vs. heap, I am not too sure. Paging @senocular and @krilnon :brain:

1 Like