[jdk21u-dev] RFR: 8337994: [REDO] Native memory leak when not recording any events

Goetz Lindenmaier goetz at openjdk.org
Thu Dec 12 07:33:44 UTC 2024


On Mon, 11 Nov 2024 18:17:06 GMT, Boris Ulasevich <bulasevich at openjdk.org> wrote:

>> 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)
>> ...
>> -                 ...
>
>> Hi @bulasevich, can this wait for the April update? It would get some more test coverage.
> 
> Hi @GoeLin 
> In my opinion, this bug could have a significant impact on customers, and it would be ideal to fix it as soon as possible. However, I understand that some reasonable patience is necessary. I'm not opposed to waiting for the next update.

Hi @bulasevich, @phohensee,
yes, this is easy to reproduce. 
I think we should backout this if there is not a simple and quick solution.
I will create a backout change around 14:00 CET, this should make the build of our nightly tests.

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

PR Comment: https://git.openjdk.org/jdk21u-dev/pull/1095#issuecomment-2538016182


More information about the jdk-updates-dev mailing list