Skip to content

smalloc: do not track external memory#1375

Closed
indutny wants to merge 2 commits into
nodejs:v1.xfrom
indutny:fix/smalloc-ownership-track
Closed

smalloc: do not track external memory#1375
indutny wants to merge 2 commits into
nodejs:v1.xfrom
indutny:fix/smalloc-ownership-track

Conversation

@indutny

@indutny indutny commented Apr 8, 2015

Copy link
Copy Markdown
Member

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
Comment thread src/smalloc.cc Outdated

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

LGTM if the CI is happy.

@indutny

indutny commented Apr 8, 2015

Copy link
Copy Markdown
Member Author

@indutny

indutny commented Apr 8, 2015

Copy link
Copy Markdown
Member Author

Thank you!

@Fishrock123

Copy link
Copy Markdown
Contributor

win2008r2 is just timers defying.. time. Again.

@indutny

indutny commented Apr 8, 2015

Copy link
Copy Markdown
Member Author

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 <info@bnoordhuis.nl>
@indutny

indutny commented Apr 8, 2015

Copy link
Copy Markdown
Member Author

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