RFR: 8284549: JFR: FieldTable leaks FieldInfoTable member

Thomas Stuefe stuefe at openjdk.java.net
Sat Apr 9 06:58:42 UTC 2022


On Thu, 7 Apr 2022 20:58:23 GMT, Zhengyu Gu <zgu at openjdk.org> wrote:

> `FieldTable` is a `ResourceObj` and it has a member points to `FieldInfoTable`, which is a `CHeapObj`.
> 
> Since ResouceObj's destructor is never called, so it can not depend on `FieldTable`s destructor to  free `FieldInfoTable`, it needs to be freed explicitly.

Hi Zhengyu,

overall ok. Small nits inline.

Cheers, Thomas

src/hotspot/share/jfr/leakprofiler/checkpoint/objectSampleWriter.cpp line 619:

> 617:   array_infos = NULL;
> 618:   field_infos = NULL;
> 619:   root_infos = NULL;

If the assumption is that only one Writer uses these global variables at a time, I'd be happier with some asserts here.

src/hotspot/share/jfr/leakprofiler/checkpoint/objectSampleWriter.cpp line 626:

> 624: 
> 625:   if (field_infos != NULL) {
> 626:     field_infos->clear();

In other places, for in-place created objects, we just call the destructor manually, with a clarifying comment. I would find that a bit clearer.

src/hotspot/share/jfr/leakprofiler/checkpoint/objectSampleWriter.cpp line 632:

> 630:   ref_infos = NULL;
> 631:   array_infos = NULL;
> 632:   root_infos = NULL;

Maybe add a comment that these are RA allocated and therefore don't need to be destructed; otherwise this looks like a leak.

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

Changes requested by stuefe (Reviewer).

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


More information about the hotspot-jfr-dev mailing list