Skip to content

Instantly share code, notes, and snippets.

@benwaffle
Created May 10, 2014 19:01
Show Gist options
  • Select an option

  • Save benwaffle/014496383e54d1b7fb70 to your computer and use it in GitHub Desktop.

Select an option

Save benwaffle/014496383e54d1b7fb70 to your computer and use it in GitHub Desktop.
CrashJVM.java
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