RFR: JDK-8269092: Add OldObjectSampleEvent.allocationSize field

Erik Gahlin egahlin at openjdk.java.net
Thu Jun 24 10:37:28 UTC 2021


On Tue, 22 Jun 2021 08:32:56 GMT, Ludovic Henry <luhenry at openjdk.org> wrote:

> The data is already available in ObjectSample.allocated and getting this data
> in another way is complicated (via Instrumentation for example). Having the
> size of the objects also allows to augment the memory leak analysis based on
> the object size impact on top of based on the object count impact.

test/jdk/jdk/jfr/event/oldobject/TestAllocationSize.java line 81:

> 79:             Events.hasEvents(events);
> 80:             for (RecordedEvent e : events) {
> 81:                 if (e.getEventType().getName().equals(EventNames.OldObjectSample)) {

No need to check against event name. 

If only OldObjectSample event has been enabled, other events won't be in the recording.

test/jdk/jdk/jfr/event/oldobject/TestAllocationSize.java line 84:

> 82:                     RecordedObject object = e.getValue("object");
> 83:                     RecordedClass type = object.getValue("type");
> 84:                     if ((long)e.getValue("allocationSize") <= 0) {

You could use e.getLong(...) here.

-------------

PR: https://git.openjdk.java.net/jdk/pull/4549


More information about the hotspot-jfr-dev mailing list