Giter Site home page Giter Site logo

heap-cleaner's Introduction

Heap Cleaner - reduces the V8 heapsnapshot and focuses on a specific node for analyzing a memory leak.

Usage

Just run src/bin.ts with the input file and optionally pass in a node id(s) to focus as last parameter(s). If the node to focus is not provided, the program will try to find a detached windows and focus on it. Output is minified heapsnapshot file (original file name with focused node id suffix).

npm run start sample/sample.heapsnapshot
npm run start sample/sample.heapsnapshot 123 456 789

or

node --require ts-node/register --max-old-space-size=32768 src/bin.ts sample/sample.heapsnapshot

or

npx heap-cleaner sample/sample.heapsnapshot

without need to clone the repo, but you will not be able to extend memory for big heap snapshots.

heap-cleaner's People

Contributors

dolezel avatar peledni avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

heap-cleaner's Issues

Properly handle retainers for WeakMaps/WeakSets

First off, thank you for creating this tool! It works amazingly well, and solves many of the problems with working with heap snapshots that I mentioned in my blog post and this issue I opened on Chromium.

One issue I notice, though, is that when identifying the retainers for an object with a given ID, it doesn't properly take WeakMaps/WeakSets into account. For instance:

  1. When an object is the key in a WeakMap, then the WeakMap itself (and its retainers) are not really retaining the object. So in this case the WeakMap is irrelevant and should be removed. However, the tool does not do this.
  2. When the object is the value in a WeakMap, then the key is what's retaining the object (plus the retainers of the WeakMap itself). However, the tool does not seem to follow the retainers for the key (meaning you would have to do a separate analysis for that object ID, which can get impractical in an object graph with many WeakMaps/WeakSets).

Thanks again for the tool! I would be excited to see it integrated into the Chrome DevTools themselves, and to improve the handling of WeakMaps/WeakSets. ๐Ÿ™‚

Error: Cannot find node with name: Detached Window

Hi! I can't reduce heap snapshot with your tool :(

Heap snapshot: Heap-20201006T090550.heapsnapshot.zip
I took it from the background page of Extension Reloader

-> % node --require ts-node/register --max-old-space-size=8192 --stack-size=160000000 src/cleaner.ts ~/Downloads/Heap-20201006T090550.heapsnapshot 
[ '/Users/vlad/Downloads/Heap-20201006T090550.heapsnapshot' ]
reading file - start!
reading file - end!
Building graph - start!
reading nodes - start!
reading nodes - end. Read: 23677 nodes.
reading edges - start!
reading edges - end. Read: 83162 edges.
Building graph - end!
(node:91261) UnhandledPromiseRejectionWarning: Error: Cannot find node with name: Detached Window
    at GraphManager.findNodeByName (/Users/vlad/dev/heap-cleaner/src/graph-manager.ts:290:11)
    at /Users/vlad/dev/heap-cleaner/src/cleaner.ts:14:22
    at Generator.next (<anonymous>)
    at fulfilled (/Users/vlad/dev/heap-cleaner/src/cleaner.ts:5:58)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.