Created
August 18, 2019 04:44
-
-
Save ashkrit/3e721ef22c01a126bdf26386d4e01c1f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class MemoryAllocator { | |
| public static final int KB = 1024; | |
| static int mbToAllocate = Integer.getInteger("mb", 1000); | |
| public static void main(String[] args) { | |
| System.out.println(String.format("Start allocation of %s MBs", mbToAllocate)); | |
| for (var i = 0; i < mbToAllocate; i++) { | |
| var garbage = new byte[KB * KB]; | |
| } | |
| System.out.println("I was Alive after allocation"); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment