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

JavaÀ¬»ø»ØÊÕµ÷ÓÅ

JavaÀ¬»ø»ØÊÕµ÷ÓÅ
ÔÚJavaÖУ¬Í¨³£Í¨Ñ¶ÀàÐ͵ķþÎñÆ÷¶ÔGC(Garbage Collection)±È½ÏÃô¸Ð¡£Í¨³£Í¨Ñ¶·þÎñÆ÷ÿÃëÐèÒª´¦Àí´óÁ¿½ø³öµÄÊý¾Ý°ü£¬ÐèÒª½âÎö£¬·Ö½â³É²»Í¬µÄÒµÎñÂß¼­¶ÔÏó²¢×öÏà¹ØµÄÒµÎñ´¦Àí£¬ÕâÑù»áµ¼Ö´óÁ¿µÄÁÙʱ¶ÔÏó±»´´½¨ºÍ»ØÊÕ¡£Í¬Ê±·þÎñÆ÷Èç¹ûÐèҪͬʱ±£´æÓû§×´Ì¬µÄ»°£¬ÓÖ»á²úÉúºÜ¶àÓÀ¾ÃµÄ¶ÔÏ󣬱ÈÈçÓû§session¡£ÒµÎñÔ½¸´ÔÓµÄÓ¦ÓÃÍùÍùÓû§session°üº¬µÄÒýÓöÔÏó¾ÍÔ½¶à¡£ÕâÑùÔÚ¼«¶ËÇé¿öÏ»ᷢÉúÁ½¼þÊÂÇ飬long gc pause time »ò out of memory¡£
 Ò»£¬Òª½â¾ölong pause timeÊ×ÏÈÒªÁ˽âJVMÖÐheapµÄ½á¹¹

java gc heap
java gc heap Java HeapΪʲôҪ·Ö³É¼¸¸ö²»Í¬µÄ´ú(generation)? ÓÉÓÚ80%-98%µÄ¶ÔÏóµÄÉú´æÖÜÆں̣ܶ¬´ó²¿·ÖжÔÏó´æ·ÅÔÚyoung generation¿ÉÒԺܸßЧµÄ»ØÊÕ£¬±ÜÃâ±éÀúËùÓжÔÏó¡£ youngÓëoldÖÐÄÚ´æ·ÖÅäµÄËã·¨ÍêÈ«²»Í¬¡£young generationÖÐÓÉÓÚ´æ»îµÄºÜÉÙ£¬Òªmark, sweep È»ºóÔÙ compact Ê£ÓàµÄ¶ÔÏó±È½ÏºÄʱ£¬¸É´à°Ñ live object copy µ½ÁíÍâÒ»¸ö¿Õ¼ä¸ü¸ßЧ¡£old generationÍêÈ«Ïà·´£¬ÀïÃæµÄ live object ±ä»¯½ÏÉÙ¡£Òò´Ë²ÉÓà mark-sweep-compact¸üºÏÊÊ¡£
¶þ£¬JavaÖÐËÄÖÖÀ¬»ø»ØÊÕËã·¨
JavaÖÐÓÐËÄÖÖ²»Í¬µÄ»ØÊÕËã·¨£¬¶ÔÓ¦µÄÆô¶¯²ÎÊýΪ
–XX:+UseSerialGC
–XX:+UseParallelGC
–XX:+UseParallelOldGC
–XX:+UseConcMarkSweepGC
1. Serial Collector ´ó²¿·Öƽ̨»òÕßÇ¿ÖÆ java -client ĬÈÏ»áʹÓÃÕâÖÖ¡£ young generationËã·¨ = serial old generationËã·¨ = serial (mark-sweep-compact) ÕâÖÖ·½·¨µÄȱµãºÜÃ÷ÏÔ£¬stop-the-world, ËÙ¶ÈÂý¡£·þÎñÆ÷Ó¦Óò»ÍƼöʹÓá£
2. Parallel Collector ÔÚlinux x64ÉÏĬÈÏÊÇÕâÖÖ£¬ÆäËûƽ̨Ҫ¼Ó java -server ²ÎÊý²Å»áĬÈÏÑ¡ÓÃÕâÖÖ¡£ young = parallel£¬¶à¸öthreadͬʱcopy old = mark-sweep-compact = 1 Óŵ㣺ÐÂÉú´ú»ØÊÕ¸ü¿ì¡£ÒòΪϵͳ´ó²¿·Öʱ¼ä×öµÄgc¶¼ÊÇÐÂÉú´úµÄ£¬ÕâÑùÌá¸ßÁËthroughput(cpuÓÃÓÚ·Çgcʱ¼ä) ȱµã£ºµ±ÔËÐÐÔÚ8G/16G serverÉÏold generation live objectÌ«¶àʱºòpause time¹ý³¤
3. Parallel Compact Collector (ParallelOld) young = parallel = 2 old = parallel£¬·Ö³É¶à¸ö¶ÀÁ¢µÄµ¥Ôª£¬Èç¹ûµ¥ÔªÖÐlive objectÉÙÔò»ØÊÕ£¬¶àÔòÌø¹ýÓŵ㣺old old generationÉÏÐÔÄÜ½Ï parallel ·½Ê½ÓÐÌá¸ßȱµã£º´ó²¿·Öserverϵͳold generationÄÚ´æÕ¼Óûá´ïµ½60%-80%, ûÓÐÄÇô¶àÀíÏëµÄµ¥Ôªlive objectºÜÉÙ·½±ãѸËÙ»ØÊÕ£¬Í¬Ê±compact·½Ã濪Ïú±ÈÆðparallel²


Ïà¹ØÎĵµ£º

Java NIO APIÏê½â

 
Java NIO APIÏê½â
ÔÚJDK
1.4ÒÔÇ°£¬JavaµÄIO²Ù×÷¼¯ÖÐÔÚjava.ioÕâ¸ö°üÖУ¬ÊÇ»ùÓÚÁ÷µÄ×èÈû£¨blocking£©API¡£¶ÔÓÚ´ó¶àÊýÓ¦ÓÃÀ´Ëµ£¬ÕâÑùµÄAPIʹÓúܷ½
±ã£¬È»¶ø£¬Ò»Ð©¶ÔÐÔÄÜÒªÇó½Ï¸ßµÄÓ¦Óã¬ÓÈÆäÊÇ·þÎñ¶ËÓ¦Óã¬ÍùÍùÐèÒªÒ»¸ö¸üΪÓÐЧµÄ·½Ê½À´´¦ÀíIO¡£´ÓJDK 1.4Æð£¬NIO
API×÷Ϊһ¸ö»ùÓÚ»º³åÇø£¬²¢ÄÜÌṩ·Ç×èÈû(non-blo ......

javaʹÓÃrocksawºÍvserv tcpipʵÏÖ»ùÓÚICMPµÄPing¹¦ÄÜ

Ò»£º×¼±¸ www.savarese.org download
 1.  rocksaw-1.0.0-src.tar.gz
 2.  vserv-tcpip-0.9.2-src.tar.gz
¶þ£º±àÒëÔ´ÎļþµÃµ½jar°ü ʹÓÃAnt
 1.  build vserv-tcpip-0.9.2-src
      ÔÚvserv-tcpip-0.9.2Ŀ¼ÏÂÃ潨һ¸ötestsĿ¼£¬È»ºóÔÚcmd´°¿ÚϽøÈë ......

java×ÀÃæ³ÌÐòÖ®Òþ²ØÊó±ê

Òþ²Ø´°ÌåÄÚµÄÊó±êÖ¸Õ룬ֱ½ÓÉÏ´úÂë
import java.awt.Image;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.image.MemoryImageSource;
import javax.swing.JFrame;
public class HideCursor extends JFrame {
 HideCursor() {
  this.setBounds(300, 300, 300, 300);
 &nb ......

Ó²»Ø³µ¡¢Èí»Ø³µ¡¢javaתÒå×Ö·û

Èí»Ø³µ£¨Soft Return£©£ºÈí»Ø³µÊÇÔÚ×Ö´¦Àí³ÌÐòÖÐ×÷Ϊ×Ô¶¯ÒÆÐй¦ÄܵÄÒ»²¿·Ö×Ô¶¯²åÈëµÄ£¬Ò²½Ð»»Ðзû£¬ÔÚwordÖп´²»¼û¡£Èç¹ûÎı¾Ò»Ðеij¤¶È³¬¹ýÎĵµËù¶¨ÒåµÄÓұ߾àʱ£¬¼´µ±Ç°ÐÐûÓÐ×ã¹»µÄ¿Õ¼ä·ÅÖÃÏÂÒ»¸ö×Ö·ûʱ£¬ÎÄ×Ö´¦ÀíÈí¼þ½«ÔÚÕâÒ»ÐÐÎı¾µÄĩβ×Ô¶¯²åÈëÒ»¸öÈí»Ø³µ·û£¬Îı¾ÁíÆðÒ»ÐС£Õâ¸öÈí»Ø³µ·ûÊÇÓɱ༭³ÌÐò×Ô¶¯²úÉúµÄ£¬½Ð× ......

JAVA ÍøÉÏÊ°ÒÅ

public String makeStars(int size, char ch) {
    if(size < 1) {
        throw new IllegalArgumentException("size must be greater than 0");
    }
    char[] chs = new char[size];
    for(int i = 0; ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ