Java heap space³ö´íÔÒò[ת]
ʹÓÃJava³ÌÐò´ÓÊý¾Ý¿âÖвéѯ´óÁ¿µÄÊý¾ÝʱÈÝÒ׳öÏÖÒì³£:
java.lang.OutOfMemoryError: Java heap space
ÔÚJVMÖÐÈç¹û98£¥µÄʱ¼äÊÇÓÃÓÚGCÇÒ¿ÉÓÃµÄ Heap size ²»×ã2£¥µÄʱºò½«Å׳ö´ËÒì³£ÐÅÏ¢¡£
»¹ÓÐʹÓÃjxl¶ÁдexcelÎļþʱ£¬Í¬Ê±¶ÁÈëËùÓмǼ£¬Ò²ÈÝÒ׳öÏÖÕâ¸öÎÊÌâ¡£
JVM¶ÑµÄÉèÖÃÊÇÖ¸java³ÌÐòÔËÐйý³ÌÖÐJVM¿ÉÒÔµ÷ÅäʹÓõÄÄÚ´æ¿Õ¼äµÄÉèÖÃ.JVMÔÚÆô¶¯µÄʱºò»á×Ô¶¯ÉèÖÃHeap sizeµÄÖµ£¬Æä³õʼ¿Õ¼ä(¼´-Xms)ÊÇÎïÀíÄÚ´æµÄ1/64£¬×î´ó¿Õ¼ä(-Xmx)ÊÇÎïÀíÄÚ´æµÄ1/4¡£¿ÉÒÔÀûÓÃJVMÌṩµÄ-Xmn -Xms -XmxµÈÑ¡Ïî¿É½øÐÐÉèÖá£
ÀýÈ磺java -jar -Xmn16m -Xms64m -Xmx128m MyApp.jar
Èç¹ûHeap SizeÉèÖÃƫС£¬³ýÁËÕâЩÒì³£ÐÅÏ¢Í⣬»¹»á·¢ÏÖ³ÌÐòµÄÏìÓ¦ËٶȱäÂýÁË¡£GCÕ¼ÓÃÁ˸ü¶àµÄʱ¼ä£¬¶øÓ¦Ó÷ÖÅäµ½µÄÖ´ÐÐʱ¼ä½ÏÉÙ¡£
Heap Size ×î´ó²»Òª³¬¹ý¿ÉÓÃÎïÀíÄÚ´æµÄ80£¥£¬Ò»°ãµÄÒª½«-XmsºÍ-XmxÑ¡ÏîÉèÖÃΪÏàͬ£¬¶ø-XmnΪ1/4µÄ-XmxÖµ¡£
Heap sizeµÄ -Xms -Xmn ÉèÖò»Òª³¬³öÎïÀíÄÚ´æµÄ´óС¡£·ñÔò»áÌáʾ“Error occurred during initialization of VM Could not reserve enough space for object heap ”¡£
½â¾ö°ì·¨£º
java³ÌÐò
java -Xms32m -Xmx800m className
¾ÍÊÇÔÚÖ´ÐÐJAVAÀàÎļþʱ¼ÓÉÏÕâ¸ö²ÎÊý£¬ÆäÖÐclassNameÊÇÐèÒªÖ´ÐеÄȫ·¾¶ÀàÃû¡£
ÓÃEclispe ÔÚEclipse ->run -arguments ÖеÄVM arguments ÖÐÊäÈë-Xms32m -Xmx800m¡£
tomcat
windows ¸ü¸Äϵͳ»·¾³±äÁ¿
¼ÓÉÏJAVA_OPTS=-Xms64m -Xmx512m
Linux ÔÚ{tomcat_home}/bin/catalina.shµÄÇ°Ã棬¼Ó
set JAVA_OPTS='-Xms64 -Xmx512'
ÔÒò
£¨1£©²»ÒªÊÔͼȥ¼Ù¶¨À¬»øÊÕ¼¯·¢ÉúµÄʱ¼ä£¬ÕâÒ»Çж¼ÊÇδ֪µÄ¡£·½·¨ÖеÄÒ»¸öÁÙʱ¶ÔÏóÔÚ·½·¨µ÷ÓÃÍê±Ïºó¾Í±ä³ÉÁËÎÞÓöÔÏó£¬Õâ¸öʱºòËüÕ¼ÓõÄÄÚ´æ¾Í¿ÉÒÔ±»ÊÍ·Å¡£
¡¡¡¡£¨2£©JavaÖÐÌṩÁËһЩºÍÀ¬»øÊÕ¼¯´ò½»µÀµÄÀ࣬¶øÇÒÌṩÁËÒ»ÖÖÇ¿ÐÐÖ´ÐÐÀ¬»øÊÕ¼¯µÄ·½·¨--µ÷ÓÃSystem.gc()£¬µ«ÕâͬÑùÊǸö²»È·¶¨µÄ·½·¨£¬ºÜ¿ÉÄܸ÷¸öƽ̨µÄʵÏÖ»ò²»Í¬ÖÖÀàµÄJDKʵÏÖ²»»áÏàͬ¡£Java Öв¢²»±£Ö¤Ã¿´Îµ÷Óø÷½·¨¾ÍÒ»¶¨Äܹ»Æô¶¯À¬»øÊÕ¼¯£¬ËüÖ»²»¹ý»áÏòJVM·¢³öÕâÑùÒ»¸öÉêÇ룬µ½µ×ÊÇ·ñÕæÕýÖ´ÐÐÀ¬»øÊÕ¼¯£¬Ò»Çж¼ÊǸöδ֪Êý¡£
¡¡¡¡£¨3£©ÌôÑ¡ÊʺÏ×Ô¼ºµÄÀ¬»øÊÕ¼¯Æ÷ºÍËã·¨¡£Èç¹ûϵͳûÓÐÌØÊâºÍ¿Á¿ÌµÄÐÔÄÜÒªÇ󣬿ÉÒÔ²ÉÓÃJVMµÄȱʡѡÏî¡£·ñÔò¿ÉÒÔ¿¼ÂÇʹÓÃÓÐÕë¶ÔÐÔµÄÀ¬»øÊÕ¼¯Æ÷£¬±ÈÈçÔöÁ¿ÊÕ¼¯Æ÷¾Í±È½ÏÊʺÏʵʱÐÔÒªÇó½Ï¸ßµÄϵͳ֮ÖС£ÏµÍ³¾ßÓнϸߵÄÅäÖã¬ÓбȽ϶àµÄÏÐÖÃ×ÊÔ´£¬¿ÉÒÔ¿¼ÂÇʹÓò¢Ðбê¼Ç/Çå³ýÊÕ¼¯Æ÷¡£
Ïà¹ØÎĵµ£º
µ±³ÌÐòµÄij¸öÄ£¿é±»µ÷ÓõÄʱ¿Ì²»È·¶¨£¬¾ÍÀàËÆÓڵȴýij¸öʼþµÄ·¢Éú¡£Õâʱ£¬¿ÉÒÔ¶¨Òå×Ô¼ºµÄʼþ½øÐÐÏàÓ¦µÄ´¦Àí¡£±ÈÈ磬µÈ´ýÓû§µÄÒ»´ÎÊäÈëµÈ¡£JavaµÄʼþÄ£ÐÍÒÀÀµÓÚίÍУ¬Í¨¹ý»Øµ÷·½·¨½øÐÐÏàÓ¦µÄʼþ´¦Àí¡£ÔÚʼþÔ´ÖУ¬»áÓÐfireXXXEvent()¾ÍÊǼ¤»îÏàÓ¦µÄʼþ£¬ÆäÖлá±éÀúʼþÔ´µÄ¼àÌýÆ ......
Ò».¶Ñ:ÓÃnew¹Ø¼ü×Ö½¨Á¢,´æ·Å¶ÔÏóµÄÄÚÈÝ,GC¸ºÔð×Ô¶¯»ØÊÕ
ÄãÓÃÊ®¼¸¸öÂ齫ÅÆÊúÖ±µþ³ÉÒ»ÞûÕâ½Ð¶Ñ£¬Äã¿ÉÒÔ´ÓÉÏÃæ¡¢ÏÂÃæ¡¢ÖмäÈÎÒâ³é³öÒ»ÕÅÅÆ£¬Ò²¿ÉÒÔÈÎÒâ²åÈëÒ»ÕÅ¡£ËùÒԶѺÜÁé»î£¬µ«²»°²È«¡£¶ÔÓÚ¶ÔÏó£¬ÎÒÃÇÒª¶¯Ì¬µØ´´½¨¡¢Ïú»Ù£¬²»ÄÜ˵ºó´´½¨µÄ¶ÔÏóûÓÐÏú»Ù£¬ÏÈÇ°´´½¨µÄ¶ÔÏó¾Í²»ÄÜÏú»Ù£¬ÄÇÑùµÄ»°ÎÒÃǵijÌÐò¾Í´ç²½ÄÑÐУ¬ËùÒÔJavaÖ ......
×¢£º±¾ÎÄת×Ôhttp://lavasoft.blog.51cto.com µÄJavaÐéÄâ»ú£¨JVM£©²ÎÊýÅäÖÃ˵Ã÷£¬×÷Ϊ×Ô¼ºÑ§Ï°Óá£
JavaÐéÄâ»ú£¨JVM£©²ÎÊýÅäÖÃ˵Ã÷
ÔÚJava¡¢J2EE´óÐÍÓ¦ÓÃÖУ¬JVM·Ç±ê×¼²ÎÊýµÄÅäÖÃÖ±½Ó¹Øϵµ½Õû¸öϵͳµÄÐÔÄÜ¡£
JVM·Ç±ê×¼²ÎÊýÖ¸µÄÊÇJVMµ×²ãµÄһЩÅäÖòÎÊý£¬ÕâЩ²ÎÊýÔÚÒ»°ã¿ª·¢ÖÐĬÈϼ´¿É£¬²»ÐèÒªÈκÎÅäÖᣵ«ÊÇÔÚÉú ......
´ó¼ÒºÃ£¬Çë°´ÕÕÏÂͼ¸ñʽÌîдÄãµÄ¼òÀú£¬·¢Ë͵½Óʼþ loveyingjiaping@126.com
¹«Ë¾×ܲ¿ÔÚº¼ÖÝÎ÷ºþ¿Æ¼¼Ô°¸½½ü£¬¸£Àû´ýÓöºÃ£¬ÎåÏÕÒ»½ð£¬
²¹Ìù£º·¹Ìù¡¢½»Í¨·Ñ¡¢Í¨Ñ¶·Ñ¡¢ÄêÖÕ½±¡¢¹ý½Ú·Ñ……
±±¾©·Ö¹«Ë¾¼¼Êõ²¿¾Àí£¨¸±¾Àí£©¸ÚλְÔðºÍÈÎÖ°Ìõ¼þÈçÏ£º
n ¸ÚλְÔð£º
1. & ......
Ê×Ïȵ½¸Ãhttp://ostermiller.org/utils/download.html µØÖ·ÏÂÔØcom.Ostermiller.util cvsµÄjar°ü¡£
public class CsvFileParser{
private LabeledCSVParser csvParser;//csv½âÎöÆ÷£¬¶ÔÓÚµÚÒ»ÐеıíÍ·ÐÅÏ¢£¬×Ô¶¯¼ÓÔØΪË÷Òý¹Ø¼ü×Ö
private int currLineNum = -1;//ÎļþËù¶Áµ½ÐÐÊý
private String[] currLi ......