RFR: 8300032: DwarfParser resource leak

Chris Plummer cjplummer at openjdk.org
Fri Jan 13 21:09:15 UTC 2023


On Fri, 13 Jan 2023 07:45:59 GMT, Daniel Jeliński <djelinski at openjdk.org> wrote:

> As far as I could tell, the cleaners you pointed out use local variables only. As long as the lambda does not reference any object fields or instance methods, `this` is not captured.

Ok. So the lambda needs to reference a field of the `this` in order to capture `this`. I guess that's why you see hacks like this:

        // Register a cleaning function to close the handle
        final long local_handle = handle;    // local to prevent capture of this
        CleanerFactory.cleaner().register(this, () -> closeHandle(local_handle));

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

PR: https://git.openjdk.org/jdk/pull/11965


More information about the serviceability-dev mailing list