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

smalloc: do not track external memory #1375

Closed
wants to merge 2 commits into from

Conversation

indutny
Copy link
Member

@indutny indutny commented Apr 8, 2015

The memory that was allocated outside of the smalloc.cc should not be
tracked using AdjustAmountOfExternalAllocatedMemory. There are no
potential issues except triggering V8's GC way too often.

In fact, heap.js is creating a buffer out of the pointer, and since it
doesn't know the size of the pointer - it just creates the maximum
possible Buffer instance with a no-op free callback and no hint.

R=@trevnorris or @bnoordhuis

The memory that was allocated outside of the `smalloc.cc` should not be
tracked using `AdjustAmountOfExternalAllocatedMemory`. There are no
potential issues except triggering V8's GC way too often.

In fact, `heap.js` is creating a buffer out of the pointer, and since it
doesn't know the size of the pointer - it just creates the maximum
possible `Buffer` instance with a no-op free callback and no hint.
@indutny indutny force-pushed the fix/smalloc-ownership-track branch from 882c657 to 1407d99 Compare April 8, 2015 14:12
callback_(static_cast<char*>(array_data), hint_);
isolate->AdjustAmountOfExternalAllocatedMemory(
-static_cast<int64_t>(sizeof(*this)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's arguably better to call Isolate::AdjustAmountOfExternalAllocatedMemory() only once. As is, the code may potentially trigger a GC twice.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@bnoordhuis
Copy link
Member

LGTM if the CI is happy.

@indutny
Copy link
Member Author

indutny commented Apr 8, 2015

@indutny
Copy link
Member Author

indutny commented Apr 8, 2015

Thank you!

@Fishrock123
Copy link
Contributor

win2008r2 is just timers defying.. time. Again.

@indutny
Copy link
Member Author

indutny commented Apr 8, 2015

I guess we are good to go?

indutny added a commit that referenced this pull request Apr 8, 2015
The memory that was allocated outside of the `smalloc.cc` should not be
tracked using `AdjustAmountOfExternalAllocatedMemory`. There are no
potential issues except triggering V8's GC way too often.

In fact, `heap.js` is creating a buffer out of the pointer, and since it
doesn't know the size of the pointer - it just creates the maximum
possible `Buffer` instance with a no-op free callback and no hint.

PR-URL: #1375
Reviewed-By: Ben Noordhuis <[email protected]>
@indutny
Copy link
Member Author

indutny commented Apr 8, 2015

Landed in ff74931, thank you!

@indutny indutny closed this Apr 8, 2015
@indutny indutny deleted the fix/smalloc-ownership-track branch April 8, 2015 15:12
@rvagg rvagg mentioned this pull request Apr 11, 2015
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.

3 participants