RFR: 8303068: Memory leak in DwarfFile::LineNumberProgram::run_line_number_program
Johan Sjölen
jsjolen at openjdk.org
Fri Feb 24 11:19:05 UTC 2023
On Fri, 24 Feb 2023 04:48:53 GMT, David Holmes <dholmes at openjdk.org> wrote:
> After allocating:
>
> _state = new (std::nothrow) LineNumberProgramState(_header);
>
> we need to `delete _state` before returning.
>
> Testing: tiers 1-3
>
> Thanks.
Hi David,
`LineNumberProgram` is used in `elFile.cpp:704`, is stack allocated and has exactly one entry point: `find_filename_and_line_number`. `LineNumberProgramState` is used only internally by `LineNumberProgramState`.
`LineNumberProgram`'s current size is 120 bytes. The size of `LineNumberProgramState` is 48 bytes.
Can't we change the type of `_state` to `LineNumberProgramState`? This bloats the size up to 168 bytes, but we no longer have to care about tracking the resource or have another heap allocation call. Yes, we have to change `->` to `.`, so the change is larger, but it's conceptually simpler.
FWIW, `_state` is also always re-allocated, so I don't see why we even need the `reset()` method on it, but that's a future RFE.
-------------
PR: https://git.openjdk.org/jdk/pull/12738
More information about the hotspot-dev
mailing list