Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Understanding Heap Profiler
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  10 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
C Snover  
View profile  
 More options Jan 22 2011, 7:18 pm
From: C Snover <goo...@zetafleet.com>
Date: Sat, 22 Jan 2011 16:18:17 -0800 (PST)
Local: Sat, Jan 22 2011 7:18 pm
Subject: Understanding Heap Profiler
Hi everyone,

I’m working on writing a short article on how to use the Memory
Timeline and Heap Snapshot tool in Google Chrome, since the
documentation at http://code.google.com/chrome/devtools/ is pretty
spartan and doesn’t really provide much useful information for people
that don’t already have an advanced knowledge of how V8’s memory
internals work (or memory management in general). Unfortunately, I’m
also coming at this from the viewpoint of someone that doesn’t
entirely “get it”, and I’m hoping that people can offer some
explanations that can help better my understanding of these features.

1. What exactly is being drilled down when going through the table?
For instance, if I expand the Array constructor, what am I looking at?
Are those a list of object types with properties that reference an
Array? Does “(closure)” mean that Array is being made available
through a closure in some other code? I’m just really not entirely
clear on these structures, and it is one of the main things I want to
make clear in my article.

2. What do the terms “(roots)” and “(global property)” mean in the
context of the heap snapshot table?

3. What, exactly, is a “(code)” object? From a brief skim of the
Chromium source, it looks like it is anything identified as being
IsCode, IsSharedFunctionInfo, or IsScript, but I don’t know what
exactly those are. My gut assumptions are that Code are blocks of JIT-
compiled code and Script is an uninterpreted chunk of script, but
those are mostly uneducated guesses. I have no clue what
SharedFunctionInfo would be. Information here would be appreciated.

Thanks in advance!

Regards,


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mikhail Naganov  
View profile  
 More options Jan 24 2011, 5:41 am
From: Mikhail Naganov <mnaga...@chromium.org>
Date: Mon, 24 Jan 2011 13:41:36 +0300
Local: Mon, Jan 24 2011 5:41 am
Subject: Re: [Chrome DevTools] Understanding Heap Profiler
Hi C Snover,

I would like to help you in your efforts. Answers are inline.

Yes, you are looking at aggregated retainers. The number in the object
column indicates the number of references.
"(closures)" are functions closures, that's right.

> 2. What do the terms “(roots)” and “(global property)” mean in the
> context of the heap snapshot table?

(roots) are GC roots -- current stack, active V8 handle scopes,
compilation cache, global handles.
(global property) are special intermediate objects that stand between
a global object (e.g. window) and an object that is referenced from
it. E.g. if an object created using constructor A is held by a global
object, then a retaining path will look like this: [global] -> (global
property) -> A. Whereas in all other cases objects reference each
other directly.

> 3. What, exactly, is a “(code)” object? From a brief skim of the
> Chromium source, it looks like it is anything identified as being
> IsCode, IsSharedFunctionInfo, or IsScript, but I don’t know what
> exactly those are. My gut assumptions are that Code are blocks of JIT-
> compiled code and Script is an uninterpreted chunk of script, but
> those are mostly uneducated guesses. I have no clue what
> SharedFunctionInfo would be. Information here would be appreciated.

(code) is everything related to compiled code. Script is like a
function but corresponds to a script body. SharedFunctionInfos are
objects that stand between functions and compiled code. Functions are
usually have a context, while SFIs are context-less. So several
functions of different contexts can share their common data in a
single SFI. SFI holds a link to the compiled code.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
C Snover  
View profile  
 More options Jan 26 2011, 10:20 pm
From: C Snover <goo...@zetafleet.com>
Date: Wed, 26 Jan 2011 19:20:44 -0800 (PST)
Local: Wed, Jan 26 2011 10:20 pm
Subject: Re: Understanding Heap Profiler
Hi Mikhail,

Thanks very much for your help. Bear with me, as I have a couple of
follow-ups, below. (Also, I accidentally replied directly to you
instead of to the list; sorry about that.)

On Jan 24, 4:41 am, Mikhail Naganov <mnaga...@chromium.org> wrote:

> (roots) are GC roots -- current stack, active V8 handle scopes,
> compilation cache, global handles.

So, could these be likened to references to objects from within the
engine itself?

> (global property) are special intermediate objects that stand between
> a global object (e.g. window) and an object that is referenced from
> it.

Why is this done?

> (code) is everything related to compiled code. Script is like a
> function but corresponds to a script body. SharedFunctionInfos are
> objects that stand between functions and compiled code. Functions are
> usually have a context, while SFIs are context-less. So several
> functions of different contexts can share their common data in a
> single SFI. SFI holds a link to the compiled code.

So, just to confirm I understand:

1. Script is any code inside a <script> block that is not part of a
function definition, e.g. <script>var foo = 42;</script>
2. SFI can be roughly considered to be a pointer to the compiled code
for a function that might be referenced in several different contexts
(e.g. var foo = function () {}, bar = {}; bar.foo = foo; both point to
the same SFI but have a different context)
3. a Function is a thin wrapper to an SFI that mostly just contains
additional information about the context that the SFI code executes in

Is that correct?

Finally, where does the source JavaScript fit in here? Is that
considered “code object” since it’s compilable/interpretable code, or
does that go in the “data object” bin since it’s uncompiled source?

Thanks again,


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mikhail Naganov  
View profile  
 More options Jan 27 2011, 8:29 am
From: Mikhail Naganov <mnaga...@chromium.org>
Date: Thu, 27 Jan 2011 16:29:33 +0300
Local: Thurs, Jan 27 2011 8:29 am
Subject: Re: [Chrome DevTools] Re: Understanding Heap Profiler

On Thu, Jan 27, 2011 at 06:20, C Snover <goo...@zetafleet.com> wrote:
> Hi Mikhail,

> Thanks very much for your help. Bear with me, as I have a couple of
> follow-ups, below. (Also, I accidentally replied directly to you
> instead of to the list; sorry about that.)

> On Jan 24, 4:41 am, Mikhail Naganov <mnaga...@chromium.org> wrote:
>> (roots) are GC roots -- current stack, active V8 handle scopes,
>> compilation cache, global handles.

> So, could these be likened to references to objects from within the
> engine itself?

Not sure what do you mean by the "references ... from within the
engine". All references are exist within the engine. If you mean
whether there can be references created by the engine for its sole
purposes -- yes, sort of. E.g. the engine has caches that reference
objects, but all such references are of a "weak" kind -- they will not
prevent an object from collection, having that there are no "strong"
references.

>> (global property) are special intermediate objects that stand between
>> a global object (e.g. window) and an object that is referenced from
>> it.

> Why is this done?

For performance. Global objects are modified frequently, and property
access optimizations that do a good job for non-global objects
(described here
http://code.google.com/apis/v8/design.html#prop_access), are not
applicable for globals. So, generated code always refers to "global
property cell"
objects, which hold real values.

>> (code) is everything related to compiled code. Script is like a
>> function but corresponds to a script body. SharedFunctionInfos are
>> objects that stand between functions and compiled code. Functions are
>> usually have a context, while SFIs are context-less. So several
>> functions of different contexts can share their common data in a
>> single SFI. SFI holds a link to the compiled code.

> So, just to confirm I understand:

> 1. Script is any code inside a <script> block that is not part of a
> function definition, e.g. <script>var foo = 42;</script>

Right.

> 2. SFI can be roughly considered to be a pointer to the compiled code
> for a function that might be referenced in several different contexts
> (e.g. var foo = function () {}, bar = {}; bar.foo = foo; both point to
> the same SFI but have a different context)

By the "context" I mean function's lexical scope. E.g. if I define the
following function:

function createAdder(n) {
  return function adder(x) { return n + x; }

}

var add3 = createAdder(3);
var add5 = createAdder(5);

The compiled code for the "adder" function is the same, but for the "add3"
the value of "n" is 3, while for "add5" "n" is 5. That means, "add3" and "add5"
refer to different Function objects, but both of them refer the same SFI.

> 3. a Function is a thin wrapper to an SFI that mostly just contains
> additional information about the context that the SFI code executes in

Yes, see above. Function refers to SFI and to the map of variable bindings.

> Is that correct?

> Finally, where does the source JavaScript fit in here? Is that
> considered “code object” since it’s compilable/interpretable code, or
> does that go in the “data object” bin since it’s uncompiled source?

No. JS source code is stored in strings.

BTW, thanks for the bug report about sorting.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
C Snover  
View profile  
 More options Jan 27 2011, 12:59 pm
From: C Snover <goo...@zetafleet.com>
Date: Thu, 27 Jan 2011 09:59:07 -0800 (PST)
Local: Thurs, Jan 27 2011 12:59 pm
Subject: Re: Understanding Heap Profiler
On Jan 27, 7:29 am, Mikhail Naganov <mnaga...@chromium.org> wrote:

> > On Jan 24, 4:41 am, Mikhail Naganov <mnaga...@chromium.org> wrote:
> >> (roots) are GC roots -- current stack, active V8 handle scopes,
> >> compilation cache, global handles.

> > So, could these be likened to references to objects from within the
> > engine itself?

> Not sure what do you mean by the "references ... from within the
> engine". All references are exist within the engine. If you mean
> whether there can be references created by the engine for its sole
> purposes -- yes, sort of. E.g. the engine has caches that reference
> objects, but all such references are of a "weak" kind -- they will not
> prevent an object from collection, having that there are no "strong"
> references.

OK. I completely misunderstood what GC roots were. I found an article
at http://www.artima.com/insidejvm/ed2/gcP.html that describes them,
so this is much clearer now.

Got it. This is very clear now. Thanks for the explanation. :)

> BTW, thanks for the bug report about sorting.

Any time. :)

I think this should be everything I need to finish up; I’ll post a
link here when the article is done. Hopefully it will be accurate and
useful. :)

Cheers,


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mikhail Naganov  
View profile  
 More options Jan 27 2011, 1:15 pm
From: Mikhail Naganov <mnaga...@chromium.org>
Date: Thu, 27 Jan 2011 21:15:24 +0300
Local: Thurs, Jan 27 2011 1:15 pm
Subject: Re: [Chrome DevTools] Re: Understanding Heap Profiler

You may also consider this article which talks specifically about V8 GC:
http://developer.palm.com/index.php?option=com_content&view=article&i...

Looking forward to see it!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
C Snover  
View profile  
 More options Jan 27 2011, 1:56 pm
From: C Snover <goo...@zetafleet.com>
Date: Thu, 27 Jan 2011 10:56:12 -0800 (PST)
Local: Thurs, Jan 27 2011 1:56 pm
Subject: Re: Understanding Heap Profiler
Hi everyone,

I’ve posted my article at http://zetafleet.com/blog/google-chromes-heap-profiler-and-memory-tim....
If there are any gross inaccuracies or things that you see that should
be clarified, please let me know at once—I’d like to make sure I am
not feeding bad information to anyone. :)

Cheers,


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mikhail Naganov  
View profile  
 More options Jan 28 2011, 5:47 am
From: Mikhail Naganov <mnaga...@chromium.org>
Date: Fri, 28 Jan 2011 13:47:59 +0300
Local: Fri, Jan 28 2011 5:47 am
Subject: Re: [Chrome DevTools] Re: Understanding Heap Profiler
Thanks for your post! We are working on improving the heap profiler,
and your requests will be soon addressed.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Davit Barbakadze  
View profile  
 More options Feb 27 2011, 1:07 pm
From: Davit Barbakadze <jaya...@gmail.com>
Date: Sun, 27 Feb 2011 10:07:49 -0800 (PST)
Local: Sun, Feb 27 2011 1:07 pm
Subject: Re: Understanding Heap Profiler
Really looking forward to see an improved Heap Profiler, which is
really lacking support for tracking down specific objects. Doesn't
look like helpful solution at the moment, although definitely is
unique.

On Jan 28, 2:47 pm, Mikhail Naganov <mnaga...@chromium.org> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Peter Reinhardt  
View profile  
 More options Mar 8 2012, 2:09 am
From: Peter Reinhardt <pe...@segment.io>
Date: Wed, 7 Mar 2012 23:09:57 -0800 (PST)
Local: Thurs, Mar 8 2012 2:09 am
Subject: Re: Understanding Heap Profiler

Hi,

Thanks for the article C Snover, super helpful. I've found the heap
profiler to be really useful in tracking down memory consumption problems
in our one-page web app.

I just posted an article about how we use the heap profiler to answer the
two big questions we had as developers: (1) how big are my objects? and (2)
when I delete them, are they really gone? which has a pre-requisite
question (3) how do I find my objects in the various heap profiler views?

http://reinpk.blogspot.com/2012/03/using-heap-profiler-in-chrome-dev-...

I hope it's useful, and I would love any feedback or suggestions you have
about better ways to answer these memory usage questions. We're really
looking forward to improvements in the profiler that make these questions
easier to answer :)

Thanks,
Peter


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »