Last active
August 29, 2015 14:16
-
-
Save sgykfjsm/bd2753a2eef8e84fc983 to your computer and use it in GitHub Desktop.
JVMのパラメータチューニングのために"java.lang.OutOfMemoryError"を発生させたい
This file contains 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.management.ManagementFactory; | |
import java.lang.management.MemoryPoolMXBean; | |
import java.lang.management.MemoryUsage; | |
public class OOM1 { | |
private static void output() { | |
java.util.List<MemoryPoolMXBean> beans = | |
ManagementFactory.getMemoryPoolMXBeans(); | |
for(MemoryPoolMXBean bean : beans) { | |
MemoryPoolMXBean permgenBean = null; | |
if(bean.getName().toLowerCase().indexOf("perm gen") >= 0) { | |
permgenBean = bean; | |
MemoryUsage currentUsage = permgenBean.getUsage(); | |
int percentageUsed = (int)((currentUsage.getUsed() * 100) | |
/ currentUsage.getMax()); | |
System.out.print("FreeMem: " + Runtime.getRuntime().freeMemory()); | |
System.out.println(" Permgen " + currentUsage.getUsed() + | |
" of " + currentUsage.getMax() + | |
" (" + percentageUsed + "%)"); | |
break; | |
} | |
} | |
} | |
public static void main(String[] args) { | |
output(); | |
main(new String[] { // http://stackoverflow.com/a/12882135 | |
(args[0] + args[0]).intern() | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
余談だけど、Vagrantで共有フォルダが作れない場合は、ゲストOSの/etc/yum.confで
を
にして、
をしてから
とすれば良い。