Skip to content

Instantly share code, notes, and snippets.

@Luavis
Created June 16, 2019 05:17
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
package benchmark;
public class GCBenchmark {
private static class MemoryAllocator {
private int[] buffer;
private MemoryAllocator(int size) {
this.buffer = new int[size];
}
public static MemoryAllocator alloc(int sizeMB) {
return new MemoryAllocator(sizeMB * 1024 * 1024 / 4);
}
}
public static void main(String[] args) {
for (int i = 0; i < 100; i++) {
MemoryAllocator.alloc(5);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment