per context memory usage reporting

24 views
Skip to first unread message

tinkerer

unread,
Dec 26, 2008, 4:39:07 PM12/26/08
to v8-users
Is there a way to determine the memory used per context? I know how
to find the total memory usage for V8 but can't seem to figure out how
to identify how much is used by each context seperately. Any
suggestions appreciated.

tink...@www.mooneydriver.com

unread,
Feb 2, 2009, 4:03:51 PM2/2/09
to v8-u...@googlegroups.com
Just wondering if anyone had any ideas on this?

Thanks.

Søren Gjesse

unread,
Feb 2, 2009, 4:26:08 PM2/2/09
to v8-u...@googlegroups.com
Hi,

One way to try to figure this out will be to walk the V8 heap with the global object for each context as the root and only count each heap object once. However if there are references from one context to another this approach will provide skewed results. Walking over the heap you should take all the internal object types into consideration to get all the references included.

Regards,
Søren

tink...@www.mooneydriver.com

unread,
Feb 2, 2009, 5:43:44 PM2/2/09
to v8-u...@googlegroups.com
Soren,

Thanks for the response. Are there any heap methods to walk the heap and
identify the items that belong to a context? I couldn't find anything.
If there is a simple way to identify the context of a heap object I guess
I could use the methods that walk to mark the heap, is there such a
function?

Thanks again!

Søren Gjesse

unread,
Feb 3, 2009, 5:08:28 AM2/3/09
to v8-u...@googlegroups.com
There is no way of telling which context an object belongs to, and the same object can easily belong to several contexts (one global object can have another global object as its property). For the debugger we have a couple of specialized heap walking functions in runtime.cc Runtime_DebugReferencedBy() and Runtime_DebugConstructedBy() which can find all objects referring to a given object and all objects constructed from any given function.

Regards,
Søren

tink...@www.mooneydriver.com

unread,
Feb 3, 2009, 4:19:11 PM2/3/09
to v8-u...@googlegroups.com
Thanks for the info. I'll checkout the debugger functions and see if they
provide some clues for me.
Reply all
Reply to author
Forward
0 new messages