# Chrome heap snapshot

**URL:** https://forum.kirupa.com/t/chrome-heap-snapshot/653097
**Category:** Uncategorized
**Created:** [August 16, 2022, 11:45am UTC](https://forum.kirupa.com/t/chrome-heap-snapshot/653097 "2022-08-16T11:45:22Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![steve.mills](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/steve.mills/32/14961_2.png) [@steve.mills](https://forum.kirupa.com/u/steve.mills)
#### Post date: [August 16, 2022, 11:45am UTC](https://forum.kirupa.com/t/chrome-heap-snapshot/653097/1 "2022-08-16T11:45:22Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![kirupa](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupa/32/11616_2.png) [@kirupa](https://forum.kirupa.com/u/kirupa)
#### Post date: [August 16, 2022, 7:04pm UTC](https://forum.kirupa.com/t/chrome-heap-snapshot/653097/2 "2022-08-16T19:04:33Z")

</div>

This one goes way beyond my level of understanding here 😛

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 🧠
