facebook/memlab

Need guidance on accessing elements in code using heap object ID

Closed this issue · 1 comments

Hi,

I'm presently engaged in a project where I'm attempting to pinpoint the specific code element responsible for a memory leak using its Heap object ID . Is there any way of doing this?

Thanks

If you want to mark those objects as memory leaks in E2E tests, consider using the leakFilter callback for self-defined leak detector to pinpoint.

If you have a single heap snapshot and just want to query a node with a specific heap object ID, use the getFullHeapFromFile API:

  const heap = await getFullHeapFromFile(heapFile);
  
  heap.nodes.forEach(node => {
    if (node.id === 12345) {
      // heap object with ID 12345 found
    }
  });

For more details, please check out the API Docs for traversing heap graphs:
https://facebook.github.io/memlab/docs/api/interfaces/core_src.IHeapNode