Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: fixed leak #3298

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,66 +28,66 @@ public static void main(String[] args) throws InterruptedException {
@SuppressWarnings("SystemOut")
private void run() throws InterruptedException {
System.out.println("Hit return to start");

// Block until consumer sends the ready signal
Scanner scanner = new Scanner(System.in, UTF_8.name());
System.out.println(scanner.nextLine());

// Allocate 1mb
for (int i = 0; i < 1024; i++) {
memory.add(new MemoryConsumer(CHUNK_SIZE));
}
try (Scanner scanner = new Scanner(System.in, UTF_8.name())) {
System.out.println(scanner.nextLine());

// Create 100mb of transient memory, invoking a number of YG gc's and promoting some to OG
for (int i = 0; i < 100 * 1024; i++) {
singleMemory = new MemoryConsumer(CHUNK_SIZE);
}

// Run full GC
System.gc();

// Allocate 30mb, 25% of which is transient
for (int i = 0; i < 30 * 1024; i++) {
if ((i % 4) == 0) {
singleMemory = new MemoryConsumer(CHUNK_SIZE);
} else {
// Allocate 1mb
for (int i = 0; i < 1024; i++) {
memory.add(new MemoryConsumer(CHUNK_SIZE));
}
} // Heap at 23.5mb

// Create 100mb of transient memory, invoking a number of YG gc's and promoting 40mb to OG
for (int i = 0; i < 100 * 1024; i++) {
singleMemory = new MemoryConsumer(CHUNK_SIZE);
}

// free up 10mb
for (int i = 0; i < 10 * 1024; i++) {
memory.remove(0);
} // Heap at 13.5mb

// Allocate 43mb, 50% of which is transient
for (int i = 0; i < 43 * 1024; i++) {
if ((i % 2) == 0) {
// Create 100mb of transient memory, invoking a number of YG gc's and promoting some to OG
for (int i = 0; i < 100 * 1024; i++) {
singleMemory = new MemoryConsumer(CHUNK_SIZE);
} else {
memory.add(new MemoryConsumer(CHUNK_SIZE));
}
} // Heap at 35mb

// free up everything
memory.clear();
// Run full GC
System.gc();

// Run full GC
System.gc();
// free up everything
memory.clear();
// Run full GC
System.gc();
// Allocate 30mb, 25% of which is transient
for (int i = 0; i < 30 * 1024; i++) {
if ((i % 4) == 0) {
singleMemory = new MemoryConsumer(CHUNK_SIZE);
} else {
memory.add(new MemoryConsumer(CHUNK_SIZE));
}
} // Heap at 23.5mb

// Seems if the JVM exits too quickly MX beans do not report, give it some time
// Create 100mb of transient memory, invoking a number of YG gc's and promoting 40mb to OG
for (int i = 0; i < 100 * 1024; i++) {
singleMemory = new MemoryConsumer(CHUNK_SIZE);
}

System.out.println("Hit return to exit");
System.out.println(scanner.nextLine());
// free up 10mb
for (int i = 0; i < 10 * 1024; i++) {
memory.remove(0);
} // Heap at 13.5mb

// Allocate 43mb, 50% of which is transient
for (int i = 0; i < 43 * 1024; i++) {
if ((i % 2) == 0) {
singleMemory = new MemoryConsumer(CHUNK_SIZE);
} else {
memory.add(new MemoryConsumer(CHUNK_SIZE));
}
} // Heap at 35mb

// free up everything
memory.clear();

// Run full GC
System.gc();
// free up everything
memory.clear();
// Run full GC
System.gc();

// Seems if the JVM exits too quickly MX beans do not report, give it some time

System.out.println("Hit return to exit");
System.out.println(scanner.nextLine());
}
}

static class MemoryConsumer {
Expand Down