Java À¬»ø»ØÊÕ µ÷ÓÅ HotSpot JV
ÒýÑÔ
ÓÐJAVA¿ª·¢¾ÑéµÄÅóÓÑÃÇÒ»¶¨Åöµ½¹ýÏÂÃæµÄÕâÖÖÇé¿ö,ÄǾÍÊÇ×Ô¼ºËù¿ª·¢µÄÓ¦ÓÃÔËÐÐÁËÒ»¶Îʱ¼äºóÆäÐÔÄÜ»ò ÕßÏìÓ¦ËٶȻáÓÐÃ÷ÏԵĽµµÍ.ÕâÊÇÓɶ෽ÃæµÄÔÒòÔì³ÉµÄ¼´ÓгÌÐò±¾ÉíµÄÓÅ»¯ÎÊÌâ,Ò²ÓÐÔËÐл·¾³ÎÊÌâ.´ËÔËÐл·¾³¼´°üÀ¨Ó²¼þ»·¾³Ò²°üÀ¨Èí¼þ»·¾³.´ó¶àÊýÈ˵ÚÒ» ¸öÄÜÏëµ½µÄ½â¾ö·½·¨ÊÇÌáÉýÓ²¼þµÄÅäÖöøºöÂÔÁ˳ÌÐò±¾ÉíµÄÔËÐл·¾³JVMÒ²ÌṩÁ˱Ƚ϶àµÄµ÷ÓÅÑ¡Ïî.±¾ÎĽ«ÖصãÃèÊöÀûÓÃJVMµÄһЩѡÏî¶ÔGC½øÐе÷ÓÅ.
Ô¼¶¨:
1.¶ÁÕßÓ¦¾ß±¸Ò»¶¨JAVAµÄ֪ʶ.
2.±¾ÎÄÖеÄJVMÑ¡Ïî¾ùÒÔSUN¹«Ë¾·¢²¼µÄHotSpot JVM 5Ϊ׼£¨²»¹ý´ó¶àÊýµÄÑ¡ÏîÔÚJVM1.3,JVM1.4ÖÐÒ²ÊÇ¿ÉÓõģ©.
3.ÒÔJAVA_HOMEÏÂdemo/jfc/SwingSet2/SwingSet2.jarΪÀý½øÐÐ˵Ã÷.
4.ÔĶÁ±¾ÎÄÐèҪһЩ¹ØÓÚGCµÄ֪ʶ£¬¿ÉÒÔµ½¸½Â¼AÖÐÁ˽âÕâЩ֪ʶ¡£
¹Ø¼ü×Ö:
JVM(javaÐéÄâ»ú),µ÷ÓÅ,GC(À¬»ø»ØÊÕ)
JVM GCµ÷ÓÅ
ΪÁËÄܹ»½«JVM GCµÄµ÷ÓÅÄܹ»Ê¹ÓÃÔÚ¾ßÌåµÄʵ¼ùµ±ÖÐ,ÏÂÃ潫ÀûÓÃÈô¸É¸öÀý×ÓÀ´ËµÃ÷GCµÄµ÷ÓÅ.
Àý1£ºHeap size ÉèÖÃ
JVM ¶ÑµÄÉèÖÃÊÇÖ¸java³ÌÐòÔËÐйý³ÌÖÐJVM¿ÉÒÔµ÷ÅäʹÓõÄÄÚ´æ¿Õ¼äµÄÉèÖÃ.JVMÔÚÆô¶¯µÄʱºò»á×Ô¶¯ÉèÖÃHeap sizeµÄÖµ£¬Æä³õʼ¿Õ¼ä(¼´-Xms)ÊÇÎïÀíÄÚ´æµÄ1/64£¬×î´ó¿Õ¼ä(-Xmx)ÊÇÎïÀíÄÚ´æµÄ1/4¡£¿ÉÒÔÀûÓÃJVMÌṩµÄ-Xmn -Xms -XmxµÈÑ¡Ïî¿É½øÐÐÉèÖá£Heap size µÄ´óСÊÇYoung Generation ºÍTenured Generaion Ö®ºÍ¡£
µ±ÔÚJAVA_HOMEÏÂdemo/jfc/SwingSet2/Ŀ¼ÏÂÖ´ÐÐÏÂÃæµÄÃüÁî¡£
java -jar -Xmn4m -Xms16m -Xmx16m SwingSet2.jar
ϵͳÊä³öΪ£º
Exception in thread "Image Fetcher 0" java.lang.OutOfMemoryError: Java heap space
Exception in thread "Image Fetcher 3" java.lang.OutOfMemoryError: Java heap space
Exception in thread "Image Fetcher 1" java.lang.OutOfMemoryError: Java heap space
Exception in thread "Image Fetcher 2" java.lang.OutOfMemoryError: Java heap space
³ýÁËÕâЩÒì³£ÐÅÏ¢Í⣬»¹»á·¢ÏÖ³ÌÐòµÄÏìÓ¦ËٶȱäÂýÁË¡£Õâ˵Ã÷Heap size ÉèÖÃƫС£¬GCÕ¼ÓÃÁ˸ü¶àµÄʱ¼ä£¬¶øÓ¦Ó÷ÖÅäµ½µÄÖ´ÐÐʱ¼ä½ÏÉÙ¡£
Ìáʾ£ºÔÚJVMÖÐÈç¹û98£¥µÄʱ¼äÊÇÓÃÓÚGCÇÒ¿ÉÓõÄHeap size ²»×ã2£¥µÄʱºò½«Å׳ö´ËÒì³£ÐÅÏ¢¡£
½«ÉÏÃæµÄÃüÁî»»³ÉÒÔÏÂÃüÁîÖ´ÐÐÔòÓ¦ÓÃÄܹ»Õý³£Ê¹Óã¬ÇÒδÅ׳öÈκÎÒì³£¡£
java -jar -Xmn4m -Xms16m -Xmx32m SwingSet2.jar
Ìáʾ£ºHeap Size ×î´ó²»Òª³¬¹ý¿ÉÓÃÎïÀíÄÚ´æµÄ80£¥£¬Ò»°ãµÄÒª½«-XmsºÍ-XmxÑ¡ÏîÉèÖÃΪÏàͬ£¬¶ø-XmnΪ1/4µÄ-XmxÖµ¡£
Àý2£ºYoung Generation£¨-Xmn£©µ
Ïà¹ØÎĵµ£º
¿ÉÒÔÓÃ×öcsdn±¸·Ý£¬Õâ¸ö·½·¨À©³äÒÔºó×ö¸öcsdn±¸·Ý¹¤¾ßµ¹ÊDz»´í
package com.tag;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import ja ......
http://www.cnblogs.com/anran_guojianjun/archive/2009/04/14/1435278.html
wait(),notify(),notifyAll()²»ÊôÓÚThreadÀà,¶øÊÇÊôÓÚObject»ù´¡Àà,Ò²¾ÍÊÇ˵ÿ¸ö¶ÔÏñ¶¼ÓÐ
wait(),notify(),notifyAll()
µÄ¹¦ÄÜ.ÒòΪ¶¼¸ö¶ÔÏñ¶¼ÓÐËø,ËøÊÇÿ¸ö¶ÔÏñµÄ»ù´¡,µ±È»²Ù×÷ËøµÄ·½·¨Ò²ÊÇ×î»ù´¡ÁË.
ÏÈ¿´java docÔõô˵:
waitµ¼Öµ± ......
Ò»°ãʹÓÃsocket½¨Á¢µÄÁ¬½Ó¶¼ÊôÓÚTCPÁ¬½ÓµÄģʽ..¾ÍÊÇÒ»°ãҪͨ¹ýÈý´ÎÎÕÊÖÀ´½¨Á¢session..È»ºóÔÙ´«ËÍÊý¾Ý..
¶øUDPģʽ²»Í¬µÄµØ·½ÔÚÓÚ..Ëü²»ÐèÒª½¨Á¢ºÍËûÈ˵ÄÁ¬½Ó..¶øÊÇÖ±½ÓÍùһ̨Ö÷»úµÄijһ¸ö¶Ë¿ÚÉÏ·¢ËÍÊý¾Ý±¨ÎÄ..
¶ÔÓÚһЩ¶ÔͨÐÅÖÊÁ¿ÒªÇ󲻸߻òÕß˵Êý¾ÝÏ¡ÊèµÄͨÐÅÀ´Ëµ..ÓÃUDPģʽÊÇÒ»¸ö²»´íµÄÑ¡Ôñ..
ÏÂÃæÊÇÒ»¸öÓÃjavaÊµÏ ......