RFR: JDK-8303181: Memory leak in ClassLoaderExt::setup_app_search_path
Justin King
jcking at openjdk.org
Wed Mar 1 16:04:52 UTC 2023
On Sun, 26 Feb 2023 22:31:23 GMT, David Holmes <dholmes at openjdk.org> wrote:
>> Fix memory leak by removing unnecessary `os::strdup` call. The string is passed as a const pointer to all functions.
>
> The problem here is that to reuse that string you have to know how/where it was originally allocated and know that it will remain safe to touch (assuming it is touched) for the lifetime of the code doing the touching. That might be true in this case but establishing that is a lot of effort, and ensuring it remains true is also then a problem. A strdup and subsequent free makes things a whole lot simpler IMO.
@dholmes-ora Switched to `os::strdup_check_oom` with `os::free` per your suggestion.
-------------
PR: https://git.openjdk.org/jdk/pull/12748
More information about the hotspot-runtime-dev
mailing list