RFR: 8252049: Native memory leak in ciMethodData ctor
Vladimir Ivanov
vlivanov at openjdk.java.net
Fri Nov 27 08:50:06 UTC 2020
`ciMethodData` embeds `MethodData` to snapshot a state from the original `MethodData` instance.
But `MethodData` embeds a `Mutex` which allocates a platform-specific implementation on C-heap.
The `Mutex` is overwritten with `0`s, but the resources aren't deallocated, so the leak occurs.
Proposed fix is to run Mutex destructor right away.
Initially, I thought about switching to `Mutex*`, but then I found that Coleen already tried that and observed a performance regression [1]. So, for now I chose the conservative approach.
In the longer term, I would consider replacing `MethodData::_extra_data_lock` with a lock-free scheme. Having a lock-per-MDO looks kind of excessive.
Testing:
- [x] verified that no memory leak observed with the reported test
- [x] tier1-4
[1] https://mail.openjdk.java.net/pipermail/hotspot-dev/2019-October/039783.html
-------------
Commit messages:
- Fix native memory leak in ciMethodData ctor
Changes: https://git.openjdk.java.net/jdk/pull/1478/files
Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=1478&range=00
Issue: https://bugs.openjdk.java.net/browse/JDK-8252049
Stats: 20 lines in 4 files changed: 15 ins; 3 del; 2 mod
Patch: https://git.openjdk.java.net/jdk/pull/1478.diff
Fetch: git fetch https://git.openjdk.java.net/jdk pull/1478/head:pull/1478
PR: https://git.openjdk.java.net/jdk/pull/1478
More information about the hotspot-compiler-dev
mailing list