Created
May 10, 2014 19:01
-
-
Save benwaffle/014496383e54d1b7fb70 to your computer and use it in GitHub Desktop.
CrashJVM.java
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
| import java.lang.reflect.Field; | |
| import sun.misc.Unsafe; | |
| public class CrashJVM { | |
| public static void main(String[] args) throws Exception { | |
| Field privUnsafe = Unsafe.class.getDeclaredField("theUnsafe"); | |
| privUnsafe.setAccessible(true); | |
| Unsafe theUnsafe = (Unsafe) privUnsafe.get(null); | |
| theUnsafe.freeMemory(1); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment