Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

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µÄȱʡѡÏî¡£·ñÔò¿ÉÒÔ¿¼ÂÇʹÓÃÓÐÕë¶ÔÐÔµÄÀ¬»øÊÕ¼¯Æ÷£¬±ÈÈçÔöÁ¿ÊÕ¼¯Æ÷¾Í±È½ÏÊʺÏʵʱÐÔÒªÇó½Ï¸ßµÄϵͳ֮ÖС£ÏµÍ³¾ßÓнϸߵÄÅäÖã¬ÓбȽ϶àµÄÏÐÖÃ×ÊÔ´£¬¿ÉÒÔ¿¼ÂÇʹÓò¢Ðбê¼Ç/Çå³ýÊÕ¼¯Æ÷¡£


Ïà¹ØÎĵµ£º

¼¸ÖÖ³£¼ûµÄÅÅÐòËã·¨µÄJAVAʵÏÖ

ÒÔO(n)µÄʱ¼äʵÏÖ¶ÔÕýÕûÊýµÄÅÅÐò¡£Ë¼Â·ÊÇ£º´Ó×îĩλ¿ªÊ¼£¬¶ÔÊý×éÖÐÿһ¸öÊýµÄµÚkλ½øÐмÆÊýÅÅÐò£¬Ö±µ½Åŵ½×î¸ßλΪֹ¡£
ȱµã£ºÖ»ÄܶÔÕýÕûÊý½øÐÐÅÅÐò£¬¶øÇÒÐèÒªÖªµÀ×î´óÕûÊýµÄ×î¸ßλ£¬Ê¹Ó÷¶Î§Ì«Ð¡¡£µ«ÕⲻʧΪһ¸öºÜÓÐȤµÄÅÅÐò£¬ÒòΪËüµß¸²Á˱ȽÏÅÅÐòµÄ´«Í³Ë¼Â·¡£
public static int[] radixSort(int[] inputs,int d){
......

java»·¾³±äÁ¿ÉèÖÃ

java»·¾³±äÁ¿ÅäÖÃ
windows xpÏÂÅäÖÃJDK»·¾³±äÁ¿£º
      1.°²×°JDK£¬°²×°¹ý³ÌÖпÉÒÔ×Ô¶¨Ò尲װĿ¼µÈÐÅÏ¢£¬ÀýÈçÎÒÃÇÑ¡Ôñ°²×°Ä¿Â¼ÎªD:\java\jdk1.5.0_08£»
¡¡ 2.°²×°Íê³Éºó£¬ÓÒ»÷“ÎҵĵçÄÔ”£¬µã»÷“ÊôÐÔ”£»
      3.Ñ¡Ôñ“¸ß¼¶”Ñ ......

×îÐÂÕÐƸ ±±¾©·Ö¹«Ë¾ ¼¼Êõ²¿¾­Àí (.net/java)

´ó¼ÒºÃ£¬Çë°´ÕÕÏÂͼ¸ñʽÌîдÄãµÄ¼òÀú£¬·¢Ë͵½Óʼþ loveyingjiaping@126.com
 
¹«Ë¾×ܲ¿ÔÚº¼ÖÝÎ÷ºþ¿Æ¼¼Ô°¸½½ü£¬¸£Àû´ýÓöºÃ£¬ÎåÏÕÒ»½ð£¬
²¹Ìù£º·¹Ìù¡¢½»Í¨·Ñ¡¢Í¨Ñ¶·Ñ¡¢ÄêÖÕ½±¡¢¹ý½Ú·Ñ……
 
±±¾©·Ö¹«Ë¾¼¼Êõ²¿¾­Àí£¨¸±¾­Àí£©¸ÚλְÔðºÍÈÎÖ°Ìõ¼þÈçÏ£º
n  ¸ÚλְÔð£º
1.   & ......

JavaϵÁн̳ÌĿ¼±í¡¾¶þ´Î¸üС¿

¡¾ÎªÁËÈöÁÕß¿´ÆðÀ´±È½ÏÓнṹ£¬ÎÒ×Ô¼ºÄâÁËÒ»·ÝÍêÕûµÄÌá¸Ù£¬¶øÇÒΪÁËʹµÃ¶ÁÕßÒ»±ßѧϰÀíÂÛÒ»±ßѧϰÏà¹Ø´úÂëÄÚÈÝ£¬ÀïÃæ90%µÄ´úÂëÎÒ¶¼ÌṩÁËÍêÕûµÄ´úÂëDemo£¬Ö±½Ó¼üÈë¹ýºóÓ¦¸Ã¾Í¿ÉÒÔÔËÐУ¬¶øÇÒÀïÃæËùÓеÄÖصãÎÒ¶¼±ê×¢³öÀ´ÁË£¬Ö÷ÒªÊÇ·½±ã¶ÁÕß²»»áÒÅ©µô¹Ø¼üµÄ֪ʶµã£¬ÒÔ¼°´úÂëµÄ×ÅÉ«£¬Ö÷ÒªÊÇΪÁË·ÀÖ¹¶ÁÕßÊÓ¾õÆ£ÀÍ¡£Ð»Ð»¸÷λָµ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ