Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add memory heap snapshot API #304

Closed
robrbecker opened this issue Aug 16, 2017 · 6 comments
Closed

Add memory heap snapshot API #304

robrbecker opened this issue Aug 16, 2017 · 6 comments
Labels

Comments

@robrbecker
Copy link

robrbecker commented Aug 16, 2017

Problem

I see there is an API for starting and stoping a timeline recording await page.tracing.start({path: 'trace.json'}); but I would like to request the ability to take a memory heap snapshot and the ability to write expectations on the snapshot data.

My use case is roughly:

  • load a page
  • load a component & do stuff
  • remove the component
  • force a garbage collection (would love a method for this as well!)
  • take a heap snapshot
  • Verify that the component is not retained in memory somehow

This would be amazing to be able to have automated headless memory leak regression testing!

Maybe something like:

var heapsnap = await page.heap.snapshot('heap1.snapshot');
expect(!heapsnap.contains('SomeClassName'))

Bonus points for an API for the memory allocation timeline that you could query for the number of objects of a type added / removed during the timeline.

@aslushnikov
Copy link
Contributor

@ak239 is claiming this!

@ebidel ebidel added the feature label Aug 16, 2017
aslushnikov added a commit to aslushnikov/puppeteer that referenced this issue Oct 11, 2017
This patch introduces Page.queryObjects and
ExecutionContext.queryObjects methods to query JavaScript heap
for objects with a certain prototype.

Fixes puppeteer#304.
aslushnikov added a commit that referenced this issue Oct 11, 2017
This patch introduces `Page.queryObjects` and
`ExecutionContext.queryObjects` methods to query JavaScript heap
for objects with a certain prototype.

Fixes #304.
@robbecker-wf
Copy link

shocked

ithinkihaveacat pushed a commit to ithinkihaveacat/puppeteer that referenced this issue Oct 31, 2017
This patch introduces `Page.queryObjects` and
`ExecutionContext.queryObjects` methods to query JavaScript heap
for objects with a certain prototype.

Fixes puppeteer#304.
@NicolasRannou
Copy link

Amazing - any snippet available to get quickly started on memory leak testing? So amazing I've been waiting for that for years!

@aslushnikov
Copy link
Contributor

@NicolasRannou we have a small demo in the api docs: page.queryObjects

@NicolasRannou
Copy link

Thanks a lot I missed that!

@georgelesica-wf
Copy link

I don't quite see how the referenced PR really resolved this issue. In order for the page.queryObjects method to be useful it seems I still need to know what I'm looking for. What I think this issue was asking for is an API to allow aggregation and possibly logging of all objects currently allocated, probably with metadata (prototype, and so on). Am I wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants