Record Heap Allocations

164 views
Skip to first unread message

mas

unread,
May 9, 2014, 11:22:45 PM5/9/14
to google-chrome-...@googlegroups.com
As it is written in ChromeDev Tools documentation, the object tracke takes heap snapshot periodically, but only the final snapshot is visible. Is there anyway, we can have access to the all the snapshots (not just the last one)?

Thanks,
Mas

Yury Semikhatsky

unread,
May 10, 2014, 9:49:47 AM5/10/14
to Google Chrome Developer Tools
Hi Mas,

The object tracker doesn't take normal snapshots as it would be too costly, instead we periodically iterate the heap and assign ids to all live objects so that we can later identify them when final snapshot is taken. As the identifiers are consecutive numbers and we know last assigned identifier after each sample we can later tell during which interval given object was allocated. This is how current implementation works doing actual snapshot only at the end of the recording so there is no intermediate snapshots you could get access to.

Yury


--
You received this message because you are subscribed to the Google Groups "Google Chrome Developer Tools" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-chrome-develo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-chrome-developer-tools/9b241e8b-1433-4925-977d-b71a49b60629%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Masoomeh Rudafshani

unread,
May 13, 2014, 6:07:22 PM5/13/14
to Google Chrome Developer Tools
Hi there,

Thanks for clarifications.
I was wondering how can I change the iteration interval? I want to get more updates from the heap. Can you please direct me to where in V8 source I can change this setting?

Thanks,
Mas


Yury Semikhatsky

unread,
May 13, 2014, 6:19:05 PM5/13/14
to Google Chrome Developer Tools
On Wed, May 14, 2014 at 12:07 AM, Masoomeh Rudafshani <masoomeh....@gmail.com> wrote:
Hi there,

Thanks for clarifications.
I was wondering how can I change the iteration interval? I want to get more updates from the heap. Can you please direct me to where in V8 source I can change this setting?

It is set in blink: https://code.google.com/p/chromium/codesearch#chromium/src/third_party/WebKit/Source/core/inspector/InspectorHeapProfilerAgent.cpp&sq=package:chromium&type=cs&l=126&rcl=1399980026 I wouldn't recommend you reduce the interval as it may significantly slow down inspected application without adding much value to the collected allocation data.


 

Masoomeh Rudafshani

unread,
May 13, 2014, 8:01:28 PM5/13/14
to Google Chrome Developer Tools
Actually, I expect to get a finer-grained view on allocation data; however, that's not possible by reducing the timer. Why? Shouldn't it be the case?

Do you know any other way I can get more updates from the heap? Not a timer-based, but something based on the size of objects or ...?

Thanks,
Mas


Yury Semikhatsky

unread,
May 15, 2014, 9:12:36 AM5/15/14
to Google Chrome Developer Tools
On Wed, May 14, 2014 at 2:01 AM, Masoomeh Rudafshani <masoomeh....@gmail.com> wrote:
Actually, I expect to get a finer-grained view on allocation data; however, that's not possible by reducing the timer. Why? Shouldn't it be the case?
Reducing the interval may give you more samples for the same period so you may get a more fine-grained picture but keep in mind that full GC is not free and it doesn't make sense to make the interval shorter than the GC pause.
 
Do you know any other way I can get more updates from the heap? Not a timer-based, but something based on the size of objects or ...?
The most common scenario the tracker is supposed to be used for is to catch memory leaks caused by some particular action. In that case the granularity should be fine enough to allow selecting time frame when the action was executed. Can you describe the problem that you are trying to solve and what makes you believe that more often updates would be helpful?
 

Masoomeh Rudafshani

unread,
May 15, 2014, 3:04:01 PM5/15/14
to Google Chrome Developer Tools
I am trying to record all objects allocations (along with their types) and I was under the impression that tracker records all allocations. It seems that since tracker misses some garbage collections, it's not possible. As I understand, tracker is useful if an object keeps staying alive (memory leak case). That's why I was thinking about reducing the interval of getting updates on the heap. 

The good thing about tracker is that it assigns a snapshotObjectId to every heap object which makes it possible to track a specific object.

Currently, I've found running chromium with heap-stats flag (works only in Debug build) allows me to track all allocations (it generates report before and after every garbage collection). However, the problem is that I can not track a specific object, since I do not find a specific Id. I can see there is an address associated with every object, but what if the object moves and its address changes? How can I track the same object over consecutive garbage collections? Any suggestion?

BTW, what is the purpose of trace_node_id in the source codes?

Thanks,
Mas


Yury Semikhatsky

unread,
May 19, 2014, 2:33:39 AM5/19/14
to Google Chrome Developer Tools

It is still not clear what problem you are trying to solve. Are you fixing a memory leak, memory bloat issue or something else? More details on the problem would be helpful.

On Thu, May 15, 2014 at 11:04 PM, Masoomeh Rudafshani <masoomeh....@gmail.com> wrote:
I am trying to record all objects allocations (along with their types) and I was under the impression that tracker records all allocations. It seems that since tracker misses some garbage collections, it's not possible. As I understand, tracker is useful if an object keeps staying alive (memory leak case). That's why I was thinking about reducing the interval of getting updates on the heap. 
Correct. The tracker is useful for identifying when an object present in the final snapshot was allocated. It provides no information about collected objects but they are usually doesn't help much in fighting memory leaks.
 
The good thing about tracker is that it assigns a snapshotObjectId to every heap object which makes it possible to track a specific object.

Currently, I've found running chromium with heap-stats flag (works only in Debug build) allows me to track all allocations (it generates report before and after every garbage collection). However, the problem is that I can not track a specific object, since I do not find a specific Id. I can see there is an address associated with every object, but what if the object moves and its address changes? How can I track the same object over consecutive garbage collections? Any suggestion?

The ids assigned to objects will persist after object moves so you can use them to identify same object in different snapshots. We keep internal map from object address to its id which is updated during GC. The map is cleared when HeapProfiler agent is disabled (HeapProfiler.disable command is sent to it or client disconnects from the devtools backend).
 
BTW, what is the purpose of trace_node_id in the source codes?

It is id of allocation stack trace top node (experimental feature) which allows to see allocation call stack for a given heap object.
 
Reply all
Reply to author
Forward
0 new messages