Skip to content

Instantly share code, notes, and snippets.

@Luavis
Created June 16, 2019 05:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Luavis/875005249182d4c536b36326bc4a509e to your computer and use it in GitHub Desktop.
Save Luavis/875005249182d4c536b36326bc4a509e to your computer and use it in GitHub Desktop.
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