Javaã§ãã¼ãé åãä½ãããã¾ã¾OutOfMemoryErrorãåºãæ¹æ³
å æ¥ããããªåé¡ãè¦ãããã®ã ãã©ããJavaã®GCã«ã¯ãã¾ã詳ãããªãã®ã§çããããããªãã£ãã
OutOfMemoryErrorãçºçãã¾ããã(ä¸ç¥)ãã¼ãã¡ã¢ãªã¯è¶³ãã¦ããããã§ããåå ã¨ãã¦ä½ãèãããã¾ããï¼
http://d.hatena.ne.jp/iad_otomamay/20130318/1363596244
ãªãã§ã ãããªãã¨æã£ã¦ããã¨ããid:moriyoshiããPermanenté åãããµããããããªãã®ãã¨ä¸è¨ããPermanenté åãã§æ¤ç´¢ãã¦ã¿ãã¨ããªãã»ã©ããããããã¨ãªã®ãã¼ã
ã¨ããããã§æ©éãããåç¾ãããã³ã¼ããæ¸ãã¦ã¿ãããã¼ãã®å¤§é¨åããã空ããªã®ã«Permanenté åã ã99%ã«ãªã£ã¦ããã®ãããããã¨æãã
Exception in thread "main" [Full GC [Tenured: 515K->515K(56896K), 0.0106600 secs] 972K->515K(82560K), [Perm : 4095K->4026K(4096K)], 0.0107050 secs] [Times: user=0.01 sys=0.00, real=0.01 secs] java.lang.OutOfMemoryError: PermGen space at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:791) at java.lang.ClassLoader.defineClass(ClassLoader.java:634) at Test.loadNext(Test.java:135) at Test.main(Test.java:142) Heap def new generation total 25664K, used 914K [0x00000007bfc00000, 0x00000007c17d0000, 0x00000007d5150000) eden space 22848K, 4% used [0x00000007bfc00000, 0x00000007bfce4878, 0x00000007c1250000) from space 2816K, 0% used [0x00000007c1250000, 0x00000007c1250000, 0x00000007c1510000) to space 2816K, 0% used [0x00000007c1510000, 0x00000007c1510000, 0x00000007c17d0000) tenured generation total 56896K, used 515K [0x00000007d5150000, 0x00000007d88e0000, 0x00000007ffc00000) the space 56896K, 0% used [0x00000007d5150000, 0x00000007d51d0e30, 0x00000007d51d1000, 0x00000007d88e0000) compacting perm gen total 4096K, used 4058K [0x00000007ffc00000, 0x0000000800000000, 0x0000000800000000) the space 4096K, 99% used [0x00000007ffc00000, 0x00000007ffff6bd8, 0x00000007ffff6c00, 0x0000000800000000) No shared spaces configured.
ã³ã¼ãã¯éè¦ãªã¨ããã ãæç²ããã¨ãããªæãã
public class Test extends ClassLoader{ static int count = 0; Class loadNext() throws ClassNotFoundException { (ä¸ç¥) return defineClass(name, b, 0, b.length); } public static void main(String args[]) throws ClassNotFoundException{ Test me = new Test(); while(true){ me.loadNext(); count++; } } }
ã¤ã¾ãã¯ã©ã¹ãåçã«çæãã¤ã¥ããã³ã¼ãã ãå ã»ã©ã®ã³ã³ã½ã¼ã«åºåã®ä¾ã§ã¯ææ©ãè½ã¨ãããã«ã-XX:PermSize=4m -XX:MaxPermSize=4mããæå®ãã¦Permanenté åãå°ããããã®ã§800åã¡ããã®ã¯ã©ã¹ãå®ç¾©ããæã§è½ã¡ãããã®è¨å®ãªãã ã¨åã®ç°å¢ã§ã¯8ä¸åã®ã¯ã©ã¹ãå®ç¾©ãããããã§è½ã¡ãã
ã½ã¼ã¹ã³ã¼ãã¯ãã¡ãããªãããã¤ãã³ã¼ããç解ããªãã¾ã¾ã³ããããã®ãå«ã§ãç解ã§ããã¾ã§èª¿æ»ããçµæ大éã®ã³ã¡ã³ããå
¥ã£ã¦ãããã©ããããã¯ä»åã®ã¹ãã¼ãªã¼ä¸ã§ã¯ããã¾ãéè¦ãããªãã®ã§ç¡è¦ãã¦ãããã ããã
https://github.com/nishio/learn_language/blob/master/oome/Test.java