Skip to content
This repository was archived by the owner on Aug 27, 2022. It is now read-only.
/ lanai Public archive

Commit 362f168

Browse files
committedJun 24, 2020
8242501: JFR: oldobject/TestG1.java can't find leaking object
Reviewed-by: mgronlun
1 parent 2ad6386 commit 362f168

File tree

3 files changed

+42
-30
lines changed

3 files changed

+42
-30
lines changed
 

‎test/jdk/jdk/jfr/event/oldobject/TestG1.java

+14-10
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,21 @@ static private class FindMe {
5454
public static void main(String[] args) throws Exception {
5555
WhiteBox.setWriteAllObjectSamples(true);
5656

57-
try (Recording r = new Recording()) {
58-
r.enable(EventNames.OldObjectSample).withStackTrace().with("cutoff", "infinity");
59-
r.start();
60-
allocateFindMe();
61-
System.gc();
62-
r.stop();
63-
List<RecordedEvent> events = Events.fromRecording(r);
64-
System.out.println(events);
65-
if (OldObjects.countMatchingEvents(events, FindMe[].class, null, null, -1, "allocateFindMe") == 0) {
66-
throw new Exception("Could not find leak with " + FindMe[].class);
57+
while (true) {
58+
try (Recording r = new Recording()) {
59+
r.enable(EventNames.OldObjectSample).withStackTrace().with("cutoff", "infinity");
60+
r.start();
61+
allocateFindMe();
62+
System.gc();
63+
r.stop();
64+
List<RecordedEvent> events = Events.fromRecording(r);
65+
System.out.println(events);
66+
if (OldObjects.countMatchingEvents(events, FindMe[].class, null, null, -1, "allocateFindMe") > 0) {
67+
return;
68+
}
69+
System.out.println("Could not find leaking object, retrying...");
6770
}
71+
list.clear();
6872
}
6973
}
7074

‎test/jdk/jdk/jfr/event/oldobject/TestParallel.java

+14-10
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,21 @@ static private class FindMe {
5454
public static void main(String[] args) throws Exception {
5555
WhiteBox.setWriteAllObjectSamples(true);
5656

57-
try (Recording r = new Recording()) {
58-
r.enable(EventNames.OldObjectSample).withStackTrace().with("cutoff", "infinity");
59-
r.start();
60-
allocateFindMe();
61-
System.gc();
62-
r.stop();
63-
List<RecordedEvent> events = Events.fromRecording(r);
64-
System.out.println(events);
65-
if (OldObjects.countMatchingEvents(events, FindMe[].class, null, null, -1, "allocateFindMe") == 0) {
66-
throw new Exception("Could not find leak with " + FindMe[].class);
57+
while (true) {
58+
try (Recording r = new Recording()) {
59+
r.enable(EventNames.OldObjectSample).withStackTrace().with("cutoff", "infinity");
60+
r.start();
61+
allocateFindMe();
62+
System.gc();
63+
r.stop();
64+
List<RecordedEvent> events = Events.fromRecording(r);
65+
System.out.println(events);
66+
if (OldObjects.countMatchingEvents(events, FindMe[].class, null, null, -1, "allocateFindMe") > 0) {
67+
return;
68+
}
69+
System.out.println("Could not find leaking object, retrying...");
6770
}
71+
list.clear();
6872
}
6973
}
7074

‎test/jdk/jdk/jfr/event/oldobject/TestSerial.java

+14-10
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,21 @@ static private class FindMe {
5454
public static void main(String[] args) throws Exception {
5555
WhiteBox.setWriteAllObjectSamples(true);
5656

57-
try (Recording r = new Recording()) {
58-
r.enable(EventNames.OldObjectSample).withStackTrace().with("cutoff", "infinity");
59-
r.start();
60-
allocateFindMe();
61-
System.gc();
62-
r.stop();
63-
List<RecordedEvent> events = Events.fromRecording(r);
64-
System.out.println(events);
65-
if (OldObjects.countMatchingEvents(events, FindMe[].class, null, null, -1, "allocateFindMe") == 0) {
66-
throw new Exception("Could not find leak with " + FindMe[].class);
57+
while (true) {
58+
try (Recording r = new Recording()) {
59+
r.enable(EventNames.OldObjectSample).withStackTrace().with("cutoff", "infinity");
60+
r.start();
61+
allocateFindMe();
62+
System.gc();
63+
r.stop();
64+
List<RecordedEvent> events = Events.fromRecording(r);
65+
System.out.println(events);
66+
if (OldObjects.countMatchingEvents(events, FindMe[].class, null, null, -1, "allocateFindMe") > 0) {
67+
return;
68+
}
69+
System.out.println("Could not find leaking object, retrying...");
6770
}
71+
list.clear();
6872
}
6973
}
7074

0 commit comments

Comments
 (0)
This repository has been archived.