Skip to content

fix: prevent race condition in heap profiler #311

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

rohitpruthi-google
Copy link
Contributor

This pull request fixes a race condition in the heap profiler that could cause
heap.profile() to return an empty profile if called immediately after heap.start().

The issue was that heap.profile() could be called before the V8 heap profiler had
collected any samples, resulting in a blank snapshot.

This change fixes the issue by introducing a polling mechanism in the C++ addon. The
GetAllocationProfile function now waits for the profiler to collect at least one sample
before returning a profile. This ensures that heap.profile() always returns a valid
profile.

Fixes #310

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

Successfully merging this pull request may close these issues.

a delay is required after heap.start and heap.profile()
1 participant