[jdk21u-dev] RFR: 8337994: [REDO] Native memory leak when not recording any events
Goetz Lindenmaier
goetz at openjdk.org
Thu Nov 7 13:25:52 UTC 2024
On Mon, 4 Nov 2024 17:28:07 GMT, Boris Ulasevich <bulasevich at openjdk.org> wrote:
>> (not a clean backport)
>> Reworked to avoid https://github.com/openjdk/jdk/pull/17328/files backport
>>
>> Functional jtreg1-3 tests are Ok.
>> Manual testing: the reproducer shows the problem is fixed with the change (see comments below)
>
> Reproducer:
>
> import jdk.jfr.consumer.RecordingStream;
>
> /**
> * Stress test to provoke the memory leak:
> * starts 1M empty threads in VM with jfr recording
> */
> public class PinnedThreadTracker implements AutoCloseable
> {
> private final RecordingStream recordingStream;
>
> public PinnedThreadTracker() {
> recordingStream = new RecordingStream();
> recordingStream.startAsync();
> System.out.println("start recording..");
> }
>
> @Override
> public void close() {
> recordingStream.close();
> }
>
> class MyThread extends Thread {
> public void run() {
> }
> }
> public void runThreads() {
> for (int i = 0; i < 100; i++) {
> for (int j = 0; j < 100; j++) {
> for (int k = 0; k < 100; k++) {
> new MyThread().start();
> }
> MyThread thr = new MyThread(); thr.start();
> try {
> thr.join();
> } catch (Exception ex) {}
> }
> System.out.print(".");
> }
> }
>
> public static void main(String a[]) {
> PinnedThreadTracker ptt = new PinnedThreadTracker();
> ptt.runThreads();
> ptt.close();
> }
> }
>
>
> Manual testing results on jdk21u:
>
> $ for i in {0..60}; do
> export PID=`ps -ax | grep java | grep PinnedThreadTracker | sed "s/^ *// ; s/ .*//"`
> jcmd $PID VM.native_memory | grep Tracing.*reserved
> sleep 1s
> done
>
> Before the change (jcmd VM.native_memory output once a second):
> - Tracing (reserved=17355KB, committed=17355KB)
> - Tracing (reserved=21646KB, committed=21646KB)
> - Tracing (reserved=25870KB, committed=25870KB)
> - Tracing (reserved=30065KB, committed=30065KB)
> ...
> - Tracing (reserved=240567KB, committed=240567KB)
> - Tracing (reserved=244519KB, committed=244519KB)
> - Tracing (reserved=248525KB, committed=248525KB)
> - Tracing (reserved=252527KB, committed=252527KB)
>
> With the fix:
> - Tracing (reserved=17655KB, committed=17655KB)
> - Tracing (reserved=18125KB, committed=18125KB)
> - Tracing (reserved=18449KB, committed=18449KB)
> - Tracing (reserved=18961KB, committed=18961KB)
> ...
> - Tracing (reserved=17443KB, committed=17443KB)
> - Tracing (reserved=17958KB, committed=17958KB)
> - Tracing (reserved=...
Hi @bulasevich, can this wait for the April update? It would get some more test coverage.
-------------
PR Comment: https://git.openjdk.org/jdk21u-dev/pull/1095#issuecomment-2462229914
More information about the jdk-updates-dev
mailing list