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

¡¾×ª¡¿ÓÅÐãJava³ÌÐòÔ±±ØÐëÁ˽âµÄGC¹¤×÷Ô­Àí

Ò»¸öÓÅÐãµÄJava³ÌÐòÔ±±ØÐëÁ˽âGCµÄ¹¤×÷Ô­Àí¡¢ÈçºÎÓÅ»¯GCµÄÐÔÄÜ¡¢ÈçºÎÓëGC½øÐÐÓÐÏ޵Ľ»»¥£¬ÒòΪÓÐһЩӦÓóÌÐò¶ÔÐÔÄÜÒªÇó½Ï¸ß£¬ÀýÈçǶÈëʽϵͳ¡¢ÊµÊ±ÏµÍ³µÈ£¬Ö»ÓÐÈ«ÃæÌáÉýÄÚ´æµÄ¹ÜÀíЧÂÊ £¬²ÅÄÜÌá¸ßÕû¸öÓ¦ÓóÌÐòµÄÐÔÄÜ¡£±¾ÆªÎÄÕÂÊ×Ïȼòµ¥½éÉÜGCµÄ¹¤×÷Ô­ÀíÖ®ºó£¬È»ºóÔÙ¶ÔGCµÄ¼¸¸ö¹Ø¼üÎÊÌâ½øÐÐÉîÈë̽ÌÖ£¬×îºóÌá³öһЩJava³ÌÐòÉè¼Æ½¨Ò飬´ÓGC½Ç¶ÈÌá¸ßJava³ÌÐòµÄÐÔÄÜ¡£



GCµÄ»ù±¾Ô­Àí



JavaµÄÄÚ´æ¹ÜÀíʵ¼ÊÉϾÍÊǶÔÏóµÄ¹ÜÀí£¬ÆäÖаüÀ¨¶ÔÏóµÄ·ÖÅäºÍÊÍ·Å¡£



¶ÔÓÚ³ÌÐòÔ±À´Ëµ£¬·ÖÅä¶ÔÏóʹÓÃnew¹Ø¼ü×Ö£»ÊͷŶÔÏóʱ£¬Ö»Òª½«¶ÔÏóËùÓÐÒýÓø³ÖµÎªnull£¬ÈóÌÐò²»Äܹ»ÔÙ·ÃÎʵ½Õâ¸ö¶ÔÏó£¬ÎÒÃdzƸöÔÏóΪ"²»¿É´ïµÄ".GC½«¸ºÔð»ØÊÕËùÓÐ"²»¿É´ï"¶ÔÏóµÄÄÚ´æ¿Õ¼ä¡£



¶ÔÓÚGCÀ´Ëµ£¬µ±³ÌÐòÔ±´´½¨¶ÔÏóʱ£¬GC¾Í¿ªÊ¼¼à¿ØÕâ¸ö¶ÔÏóµÄµØÖ·¡¢´óСÒÔ¼°Ê¹ÓÃÇé¿ö¡£Í¨³££¬GC²ÉÓÃÓÐÏòͼµÄ·½Ê½¼Ç¼ºÍ¹ÜÀí¶Ñ£¨heap£©ÖеÄËùÓжÔÏó£¨Ïê¼û ²Î¿¼×ÊÁÏ1 £©¡£Í¨¹ýÕâÖÖ·½Ê½È·¶¨ÄÄЩ¶ÔÏóÊÇ"¿É´ïµÄ"£¬ÄÄЩ¶ÔÏóÊÇ"²»¿É´ïµÄ".µ±GCÈ·¶¨Ò»Ð©¶ÔÏóΪ"²»¿É´ï"ʱ£¬GC¾ÍÓÐÔðÈλØÊÕÕâЩÄÚ´æ¿Õ¼ä¡£µ«ÊÇ£¬ÎªÁ˱£Ö¤ GCÄܹ»ÔÚ²»Í¬Æ½Ì¨ÊµÏÖµÄÎÊÌ⣬Java¹æ·¶¶ÔGCµÄºÜ¶àÐÐΪ¶¼Ã»ÓнøÐÐÑϸñµÄ¹æ¶¨¡£ÀýÈ磬¶ÔÓÚ²ÉÓÃʲôÀàÐ͵ĻØÊÕËã·¨¡¢Ê²Ã´Ê±ºò½øÐлØÊÕµÈÖØÒªÎÊÌⶼûÓÐÃ÷È·µÄ¹æ¶¨¡£Òò´Ë£¬²»Í¬µÄJVMµÄʵÏÖÕßÍùÍùÓв»Í¬µÄʵÏÖËã·¨¡£ÕâÒ²¸øJava³ÌÐòÔ±µÄ¿ª·¢´øÀ´Ðж಻ȷ¶¨ÐÔ¡£±¾ÎÄÑо¿Á˼¸¸öÓëGC¹¤×÷Ïà¹ØµÄÎÊÌ⣬ŬÁ¦¼õÉÙÕâÖÖ²»È·¶¨ÐÔ¸øJava³ÌÐò´øÀ´µÄ¸ºÃæÓ°Ïì¡£



ÔöÁ¿Ê½GC£¨ Incremental GC £©



GCÔÚJVMÖÐͨ³£ÊÇÓÉÒ»¸ö»òÒ»×é½ø³ÌÀ´ÊµÏֵģ¬Ëü±¾ÉíÒ²ºÍÓû§³ÌÐòÒ»ÑùÕ¼ÓÃheap¿Õ¼ä£¬ÔËÐÐʱҲռÓÃCPU.µ±GC½ø³ÌÔËÐÐʱ£¬Ó¦ÓóÌÐòÍ£Ö¹ÔËÐС£Òò´Ë£¬µ±GCÔËÐÐʱ¼ä½Ï³¤Ê±£¬Óû§Äܹ»¸Ðµ½ Java³ÌÐòµÄÍ£¶Ù£¬ÁíÍâÒ»·½Ã棬Èç¹ûGCÔËÐÐʱ¼äÌ«¶Ì£¬Ôò¿ÉÄܶÔÏó»ØÊÕÂÊÌ«µÍ£¬ÕâÒâζ×Å»¹ÓкܶàÓ¦¸Ã»ØÊյĶÔÏóûÓб»»ØÊÕ£¬ÈÔȻռÓôóÁ¿ÄÚ´æ¡£Òò´Ë£¬ÔÚÉè¼ÆGCµÄʱºò£¬¾Í±ØÐëÔÚÍ£¶Ùʱ¼äºÍ»ØÊÕÂÊÖ®¼ä½øÐÐȨºâ¡£Ò»¸öºÃµÄGCʵÏÖÔÊÐíÓû§¶¨Òå×Ô¼ºËùÐèÒªµÄÉèÖã¬ÀýÈçÓÐЩÄÚ´æÓÐÏÞÓÐÉ豸£¬¶ÔÄÚ´æµÄʹÓÃÁ¿·Ç³£Ãô¸Ð£¬Ï£ÍûGCÄܹ»×¼È·µÄ»ØÊÕÄڴ棬Ëü²¢²»ÔÚÒâ³ÌÐòËٶȵķÅÂý¡£ÁíÍâһЩʵʱÍøÂçÓÎÏ·£¬¾Í²»Äܹ»ÔÊÐí³ÌÐòÓг¤Ê±¼äµÄÖжϡ£ÔöÁ¿Ê½GC¾ÍÊÇͨ¹ýÒ»¶¨µÄ»ØÊÕËã·¨£¬°ÑÒ»¸ö³¤Ê±¼äµÄÖжϣ¬»®·ÖΪºÜ¶à¸öСµÄÖжϣ¬Í¨¹ýÕâÖÖ·½Ê½¼õÉÙGC¶ÔÓû§³ÌÐòµÄÓ°Ïì¡£ËäÈ»£¬ÔöÁ¿Ê½GCÔÚÕûÌåÐÔÄÜÉÏ¿ÉÄܲ»ÈçÆÕͨGCµÄЧÂʸߣ


Ïà¹ØÎĵµ£º

Java count down

public static void main(String[] args){
SimpleDateFormat da = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
Calendar calendar = Calendar.getInstance();
Date date = calendar.getTime();
String aimTime ="2010-02-03 17:30:00.000";
int count = 0;
Date aimDate = d ......

Java SwingÖеÄJTreeÄ£ÐÍ

±¾ÎĽéÉÜJava SwingÖеÄJTreeÄ£ÐÍ£¬½éÉÜÈçºÎ´´½¨¡¢Ð޸ġ¢±éÀú£¬ÉèÖÃÊ÷¡£²Î¿¼Core Java2Ïà¹ØÕ½ڼ°ÆäÔ´´úÂë¡£
SwingÊ÷ʹÓÃÈËÃÇËùÊìϤµÄÎļþ¼ÐºÍÊ÷ҶͼÀ´ÏÔʾ·Ö²ãµÄÊý¾Ý¡£Ê÷Óɽڵã×é³É£¬½Úµã¿ÉÒÔÊÇÎļþ¼Ð£¬Ò²¿ÉÒÔÊÇÊ÷Ò¶¡£Îļþ¼Ð¿ÉÒÔÓÐ×ӽڵ㣬³ý¸ù½ÚµãÖ®ÍâµÄËùÓнڵ㶼ֻÓÐÒ»¸ö¸¸½Úµã¡£¿ÕµÄÎļþ¼ÐÓëÊ÷Ò¶µÄ²»Í¬Ö®´¦¾ÍÔÚÓÚËüÔÊ ......

JavaÖÐÈÃCPU±£³ÖÔÚÒ»ÌõÖ±ÏßÉÏ


 /**
  * @param args
  */
 public static void main(String[] args) {
  long time1 = System.currentTimeMillis();
  long time2 = System.currentTimeMillis();
  while (true) {
   while ((time1 - time2) < 30)
   & ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ