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¿Õ¼ä£¬º
Ïà¹ØÎĵµ£º
import java.io.UnsupportedEncodingException;
/**
* ת»»×Ö·û´®µÄ±àÂë
*/
public class ChangeCharset {
/** 7λASCII×Ö·û£¬Ò²½Ð×÷ISO646-US¡¢Unicode×Ö·û¼¯µÄ»ù±¾À¶¡¿é */
public static final String US_ASCII = "US-ASCII";
/** ISO À¶¡×Öĸ±í No.1£¬Ò²½Ð×÷ ISO-LATIN-1 */
public static final String ISO_ ......
1.ÉùÃ÷°ü£ºpackage °üÃû
¸ÃÓï¾äÊÇ×÷ΪjavaÔ´ÎļþµÄµÚÒ»ÌõÓï¾ä Ö¸Ã÷¸ÃÔ´Îļþ¶¨ÒåµÄÀàËùÔڵİü
2.µ¼°ü£ºimport °üÃû
¸ÃÓï¾ä±ØÐëдÔÚpackageÓï¾äºÍÔ´Îļ ......
¹Ø¼ü×Ö: byte String
ÎÊÌâ1£ºjavaÖÐûÓÐʵÏÖÕâÖÖ“byte a = 0xB2 --> String b = “B2””ת»»µÄ¼òµ¥ÊµÏÖÐèÒª×Ô¼ºÊµÏÖ¡£
´ð£º×Ô¼º±àдµÄת»»º¯Êý£¬Ë¼Â·½«byteµÄ¸ßµÍ4λ·Ö¿ª£¬·Ö±ðת»»Îª¶ÔÓ¦µÄ×Ö·ûÈ»ºóºÏ³É·µ»ØµÄ×Ö·û´®¡£
java ´úÂë
public static String byteToString(byte b) { ......
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Òì³£´¦Àí×ܽá
Òì³£´¦ÀíÊdzÌÐòÉè¼ÆÖÐÒ»¸ö·Ç³£ÖØÒªµÄ·½Ã棬ҲÊdzÌÐòÉè¼ÆµÄÒ»´óÄѵ㣬´ÓC¿ªÊ¼£¬ÄãÒ²ÐíÒѾ֪µÀÈçºÎÓÃif...else...À´¿ØÖÆÒì³£ÁË£¬Ò²ÐíÊÇ×Ô·¢µÄ£¬È»¶øÕâÖÖ¿ØÖÆÒ쳣ʹ¿à£¬Í¬Ò»¸öÒì³£»òÕß´íÎóÈç¹û¶à¸öµØ·½³öÏÖ£¬ÄÇôÄãÿ¸öµØ·½¶¼Òª×öÏàͬ´¦Àí£¬¸Ð¾õÏ൱ ......