JavaÐéÄâ»ú£¨JVM£©ÖеÄÄÚ´æÉèÖÃÏê½â
ÔÚһЩ¹æÄ£ÉÔ´óµÄÓ¦ÓÃÖУ¬JavaÐéÄâ»ú£¨JVM£©µÄÄÚ´æÉèÖÃÓÈΪÖØÒª£¬ÏëÔÚÏîÄ¿ÖÐÈ¡µÃºÃµÄЧÂÊ£¬GC£¨À¬»ø»ØÊÕ£©µÄÉèÖÃÊǵÚÒ»²½¡£
PermGen space£ºÈ«³ÆÊÇPermanent Generation space.¾ÍÊÇ˵ÊÇÓÀ¾Ã±£´æµÄÇøÓò,ÓÃÓÚ´æ·ÅClassºÍMetaÐÅÏ¢,ClassÔÚ±»LoadµÄʱºò±»·ÅÈë¸ÃÇøÓòHeap space£º´æ·ÅInstance¡£
GC(Garbage Collection)Ó¦¸Ã²»»á¶ÔPermGen space½øÐÐÇåÀí,ËùÒÔÈç¹ûÄãµÄAPP»áLOADºÜ¶àCLASSµÄ»°,¾ÍºÜ¿ÉÄܳöÏÖPermGen space´íÎó
Java Heap·ÖΪ3¸öÇø
1.Young
2.Old
3.Permanent
Young±£´æ¸ÕʵÀý»¯µÄ¶ÔÏó¡£µ±¸ÃÇø±»ÌîÂúʱ£¬GC»á½«¶ÔÏóÒƵ½OldÇø¡£PermanentÇøÔò¸ºÔð±£´æ·´Éä¶ÔÏ󣬱¾ÎIJ»ÌÖÂÛ¸ÃÇø¡£
JVMµÄHeap·ÖÅä¿ÉÒÔʹÓÃ-X²ÎÊýÉ趨£¬
-Xms
³õʼHeap´óС
-Xmx
java heap×î´óÖµ
-Xmn
young generationµÄheap´óС
JVMÓÐ2¸öGCÏß³Ì
µÚÒ»¸öÏ̸߳ºÔð»ØÊÕHeapµÄYoungÇø
µÚ¶þ¸öÏß³ÌÔÚHeap²»×ãʱ£¬±éÀúHeap£¬½«Young ÇøÉý¼¶ÎªOlderÇø
OlderÇøµÄ´óСµÈÓÚ-Xmx¼õÈ¥-Xmn£¬²»Äܽ«-XmsµÄÖµÉèµÄ¹ý´ó£¬ÒòΪµÚ¶þ¸öÏ̱߳»ÆÈÔËÐлήµÍJVMµÄÐÔÄÜ¡£
ΪʲôһЩ³ÌÐòƵ·±·¢ÉúGC£¿
ÓÐÈçÏÂÔÒò£º
1.³ÌÐòÄÚµ÷ÓÃÁËSystem.gc()»òRuntime.gc()¡£
2.һЩÖмä¼þÈí¼þµ÷ÓÃ×Ô¼ºµÄGC·½·¨£¬´ËʱÐèÒªÉèÖòÎÊý½ûÖ¹ÕâЩGC¡£
3.JavaµÄHeap̫С£¬Ò»°ãĬÈϵÄHeapÖµ¶¼ºÜС¡£
4.Ƶ·±ÊµÀý»¯¶ÔÏó£¬Release¶ÔÏó ´Ëʱ¾¡Á¿±£´æ²¢ÖØÓöÔÏó£¬ÀýÈçʹÓÃStringBuffer()ºÍString()¡£
Èç¹ûÄã·¢ÏÖÿ´ÎGCºó£¬HeapµÄÊ£Óà¿Õ¼ä»áÊÇ×Ü¿Õ¼äµÄ50%£¬Õâ±íʾÄãµÄHeap´¦ÓÚ½¡¿µ×´Ì¬,Ðí¶àServer¶ËµÄJava³ÌÐòÿ´ÎGCºó×îºÃÄÜÓÐ65%µÄÊ£Óà¿Õ¼ä
¾Ñé̸֮£º
1£®Server¶ËJVM×îºÃ½«-XmsºÍ-XmxÉèΪÏàֵͬ¡£ÎªÁËÓÅ»¯GC£¬×îºÃÈÃ-XmnÖµÔ¼µÈÓÚ-XmxµÄ1/3¡£
2£®Ò»¸öGUI³ÌÐò×îºÃÊÇÿ10µ½20Ãë¼äÔËÐÐÒ»´ÎGC£¬Ã¿´ÎÔÚ°ëÃëÖ®ÄÚÍê³É¡£
×¢Ò⣺
1£®Ôö¼ÓHeapµÄ´óСËäÈ»»á½µµÍGCµÄƵÂÊ£¬µ«Ò²Ôö¼ÓÁËÿ´ÎGCµÄʱ¼ä¡£²¢ÇÒGCÔËÐÐʱ£¬ËùÓеÄÓû§Ï߳̽«ÔÝÍ££¬Ò²¾ÍÊÇGCÆڼ䣬JavaÓ¦ÓóÌÐò²»×öÈκι¤×÷¡£
2£®Heap´óС²¢²»¾ö¶¨½ø³ÌµÄÄÚ´æʹÓÃÁ¿¡£½ø³ÌµÄÄÚ´æʹÓÃÁ¿Òª´óÓÚ-Xmx¶¨ÒåµÄÖµ£¬ÒòΪJavaΪÆäËûÈÎÎñ·ÖÅäÄڴ棬ÀýÈçÿ¸öÏ̵߳ÄStackµÈ¡£
StackµÄÉ趨
ÿ¸öÏ̶߳¼ÓÐËû×Ô¼ºµÄStack¡£
-Xss
ÿ¸öÏ̵߳ÄStack´óС
StackµÄ´óСÏÞÖÆ×ÅÏ̵߳ÄÊýÁ¿¡£Èç¹ûStack¹ý´ó¾ÍºÃµ¼ÖÂÄÚ´æÒç©¡£-Xss²ÎÊý¾ö¶¨Stack´óС£¬ÀýÈç-Xss1024K¡£Èç¹ûStack̫С£¬Ò²»áµ¼ÖÂStackÒç©¡£
Ó²¼þ»·¾³
Ó²¼þ»·¾³Ò²Ó°ÏìGCµÄЧÂÊ£¬ÀýÈç»úÆ÷µÄÖÖÀ࣬Äڴ棬swap¿Õ¼ä£¬º
Ïà¹ØÎĵµ£º
¹Ø¼ü×Ö: byte String
ÎÊÌâ1£ºjavaÖÐûÓÐʵÏÖÕâÖÖ“byte a = 0xB2 --> String b = “B2””ת»»µÄ¼òµ¥ÊµÏÖÐèÒª×Ô¼ºÊµÏÖ¡£
´ð£º×Ô¼º±àдµÄת»»º¯Êý£¬Ë¼Â·½«byteµÄ¸ßµÍ4λ·Ö¿ª£¬·Ö±ðת»»Îª¶ÔÓ¦µÄ×Ö·ûÈ»ºóºÏ³É·µ»ØµÄ×Ö·û´®¡£
java ´úÂë
public static String byteToString(byte b) { ......
ÔÚÉÏÒ»¸öÎÄÕÂÀï,ÎÒÃÇ°ÑÏîÄ¿½¨ºÃÁË,²¢ÇÒÒѾ³É¹¦ÔËÐÐ,ÏÖÔÚÀ´Àí½âÏÂzkʼþÇý¶¯(event-driven)µÄ£¬»ùÓÚ×é¼þ(component-based)µÄÌصã
ÏÈÀ´µãÀíÂÛ,ʲô½Ð×ö»ùÓÚ×é¼þ,ά»ù°Ù¿ÆÀïÃæÕâôÃèÊöµÄ:»ùÓÚ×é¼þµÄÈí¼þ¹¤³Ì£¨Component-based software engineering£¬¼ò³ÆCBSE£©»ò»ùÓÚ×é¼þµÄ¿ª·¢£¨Component-Based Development£¬¼ò³ÆCBD£©ÊÇÒ ......
/**
* @param args
*/
public static void main(String[] args) {
long time1 = System.currentTimeMillis();
long time2 = System.currentTimeMillis();
while (true) {
while ((time1 - time2) < 30)
& ......
1.//propertyÎļþµÄ¶ÁÈ¡
//com.test.messageÎļþ
package com.test;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
public class Test_Messages {
private static final String BUNDLE_NAME = "com.test.messages";
private static final ResourceBundle RESOURCE_BUNDLE = Reso ......
ÔÚJAVAÖУ¬ÓÐÁù¸ö²»Í¬µÄµØ·½¿ÉÒÔ´æ´¢Êý¾Ý£º
1. ¼Ä´æÆ÷£¨register£©¡£ÕâÊÇ×î¿ìµÄ´æ´¢Çø£¬ÒòΪËüλÓÚ²»Í¬ÓÚÆäËû´æ´¢ÇøµÄµØ·½——´¦ÀíÆ÷ÄÚ²¿¡£µ«ÊǼĴæÆ÷µÄÊýÁ¿¼«ÆäÓÐÏÞ£¬ËùÒԼĴæÆ÷ÓɱàÒëÆ÷¸ù¾ÝÐèÇó½øÐзÖÅä¡£Äã²»ÄÜÖ±½Ó¿ØÖÆ £¬Ò²²»ÄÜÔÚ³ÌÐòÖиоõµ½¼Ä´æÆ÷´æÔÚµÄÈκμ£Ïó¡£
2. ¶ÑÕ»£¨stack£©¡£Î»ÓÚͨÓÃRAMÖУ¬µ ......