RFR: JDK-8303181: Memory leak in ClassLoaderExt::setup_app_search_path

David Holmes dholmes at openjdk.org
Sun Feb 26 22:34:01 UTC 2023


On Fri, 24 Feb 2023 19:23:36 GMT, Justin King <jcking 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.

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

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


More information about the hotspot-runtime-dev mailing list