Question about the priority in Old Object Sample event

Takuya Kiriyama (Fujitsu) kiriyama.takuya at fujitsu.com
Tue Jul 15 09:35:30 UTC 2025


Hi,

I'm investigating Old Object Sample event in JFR that is useful
for memory leak analysis, but I'm finding some implementation
puzzling. I'd be grateful for any insights from those with more
experience.

Old Object Sample tracks a fixed number of objects on the heap
for as long as they are live. Marcus' article [1] was very useful
for understanding this event.
However, I have doubts about the priority of the samples stored
in the priority queue. As mentioned in the article, the priority
called "span" is determined by the memory size, giving more
weight to samples that are causing more serious leaks.

The code that implements span [2]:

```
  _total_allocated += allocated;
  const size_t span = _total_allocated - _priority_queue->total();
```

Here, "_total_allocated" is the total memory size allocated so far,
and "_priority_queue->total()" is the total size of the priority queue.
Since "_total_allocated" increases monotonically, the span of samples
allocated later tends to increase as time passes

For memory leak analysis, it is very important to pick which objects
out of a large number of objects. I didn't understand why objects
generated later tend to take precedence.

Any advice would be greatly appreciated.

Regards,
Takuya


More information about the hotspot-jfr-dev mailing list