ÈçºÎ½â¾öOutOfMemoryError: Java heap space
ÈçºÎ½â¾öOutOfMemoryError: Java heap space
http://www.busfly.cn/csdn/post/OutOfMemoryError-Java-heap-space.html
ʹÓÃJava³ÌÐò´ÓÊý¾Ý¿âÖвéѯ´óÁ¿µÄÊý¾Ýʱ³öÏÖÒì³£:
java.lang.OutOfMemoryError: Java heap space
ÔÚJVMÖÐÈç¹û98£¥µÄʱ¼äÊÇÓÃÓÚGCÇÒ¿ÉÓÃµÄ Heap size ²»×ã2£¥µÄʱºò½«Å׳ö´ËÒì³£ÐÅÏ¢¡£
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”¡£
windows ¸ü¸Äϵͳ»·¾³±äÁ¿
¼ÓÉÏJAVA_OPTS=-Xms64m -Xmx512m
ÔÚ{tomcat_home}/bin/catalina.shµÄÇ°Ã棬¼Ó
set JAVA_OPTS='-Xms64 -Xmx512'
ÒòΪ³ÌÐòÒª´ÓÊý¾Ý¶ÁÈ¡½ü10WÐмǼ´¦Àí£¬µ±¶Áµ½9WµÄʱºò¾Í³öÏÖ java.lang.OutOfMemoryError: Java heap space ÕâÑùµÄ´íÎó¡£
ÔÚÍøÉÏÒ»²é¿ÉÄÜÊÇJAVAµÄ¶ÑÕ»ÉèÖÃ̫СµÄÔÒò¡£
¸ú¾ÝÍøÉϵĴ𰸴óÖÂÓÐÕâÁ½ÖÖ½â¾ö·½·¨£º
1¡¢ÉèÖû·¾³±äÁ¿
set JAVA_OPTS= -Xms32m -Xmx512m
¿ÉÒÔ¸ù¾Ý×Ô¼º»úÆ÷µÄÄÚ´æ½øÐиü¸Ä,µ«±¾È˲âÊÔÕâÖÖ·½·¨²¢Ã»Óнâ¾öÎÊÌâ¡£¿ÉÄÜÊÇ»¹ÓÐÄÄÀïÐèÒªÉèÖá£
2¡¢java -Xms32m -Xmx800m className
¾ÍÊÇÔÚÖ´ÐÐJAVAÀàÎļþʱ¼ÓÉÏÕâ¸ö²ÎÊý£¬ÆäÖÐclassNameÊÇÐèÒªÖ´ÐеÄÈ·ÀàÃû¡££¨°üÀ¨°üÃû£©
Õâ¸ö½â¾öÎÊÌâÁË¡£¶øÇÒÖ´ÐеÄËٶȱÈûÓÐÉèÖõÄʱºò¿ìºÜ¶à¡£
Èç¹ûÔÚ²âÊÔµÄʱºò¿ÉÄÜ»áÓÃEclispe Õâʱºò¾ÍÐèÒªÔÚEclipse ->run -arguments ÖеÄVM arguments ÖÐÊäÈë-Xms32m -Xmx800mÕâ¸ö²ÎÊý¾Í¿ÉÒÔÁË¡£
Ïà¹ØÎĵµ£º
create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',
@pagesize int output,--ÿҳÏÔʾ¼Ç¼ÌõÊý
@currentpage int output,--µÚ¼¸Ò³
@orderid nvarchar(50),--Ö÷¼üÅÅÐò
@sort int,--ÅÅÐò·½Ê½£¬1±íʾÉýÐò£¬0±íʾ½µÐòÅÅÁÐ
......
Ê®¶þ javaÃæÏò¶ÔÏó³ÌÐòÉè¼Æ(ÀàµÄ¼Ì³Ð)
/**
* ÀàµÄ¼Ì³Ð
*/
class Person
{
private String name;
private int age;
public String setName(String name){this.name = name;return name;}
public int setAge(int age){this.age = age;return age;}
public void getInfo ......
Ò»¡¢·ºÐÍ(Generic)
JDK5ÒÔÇ°£¬¶ÔÏó±£´æµ½¼¯ºÏÖоͻáʧȥÆäÌØÐÔ£¬È¡³öʱͨ³£Òª³ÌÐòÔ±ÊÖ¹¤½øÐÐÀàÐ͵ÄÇ¿ÖÆת»»£¬ÕâÑù²»¿É±ÜÃâ¾Í»áÒý·¢³ÌÐòµÄһЩ°²È«ÐÔÎÊÌâ
Ø·ºÐεÄ×÷Óãº
JDK5ÖеķºÐÎÔÊÐí³ÌÐòÔ±ÔÚ±àд¼¯ºÏ´úÂëʱ£¬¾ÍÏÞÖƼ¯ºÏµÄ´¦ÀíÀ ......
ÀýÈ磺һ¸ö×Ö·û´®£º123fsf¶á
¸ÄºóҪΪ£º1%2%3%f%s%f%¶á
´úÂëÈçÏÂ
String a="123fsf¶á";
char[] b=a.toCharArray();//×Ö·û´®²ð·Ö³É×Ö·û
&n ......