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

java¶ÔÏóµÄ´óСÓëÒýÓÃÀàÐÍ

±¾ÎÄÀ´×ÔºÍÄãÔÚÒ»ÆðµÄ²©¿Í£¬Ô­ÎıêÌ⣺¡¶JVMµ÷ÓÅ×ܽá(¶þ)-һЩ¸ÅÄî¡·¡£±¾ÎÄ×ܽáÁËJVM¸ÅÄîÖеÄJava¶ÔÏóµÄ´óС£¬ÒÔ¼°ÈýÖÖÒýÓÃÀàÐ͵Ķ¨ÒåÓëÇø·Ö¡£ »ù±¾Êý¾ÝµÄÀàÐ͵ĴóСÊǹ̶¨µÄ£¬ÕâÀï¾Í²»¶à˵ÁË¡£¶ÔÓÚ·Ç»ù±¾ÀàÐ͵ÄJava¶ÔÏó£¬Æä´óС¾ÍÖµµÃÉÌȶ¡£ ÔÚJavaÖУ¬Ò»¸ö¿ÕObject¶ÔÏóµÄ´óСÊÇ8byte£¬Õâ¸ö´óСֻÊDZ£´æ¶ÑÖÐÒ»¸öûÓÐÈκÎÊôÐԵĶÔÏóµÄ´óС¡£¿´ÏÂÃæÓï¾ä£º Object ob = new Object(); ÕâÑùÔÚ³ÌÐòÖÐÍê³ÉÁËÒ»¸öJava¶ÔÏóµÄÉúÃü£¬µ«ÊÇËüËùÕ¼µÄ¿Õ¼äΪ£º4byte+8byte¡£4byteÊÇÉÏÃ沿·ÖËù˵µÄJavaÕ»Öб£´æÒýÓõÄËùÐèÒªµÄ¿Õ¼ä¡£¶øÄÇ8byteÔòÊÇJava¶ÑÖжÔÏóµÄÐÅÏ¢¡£ÒòΪËùÓеÄJava·Ç»ù±¾ÀàÐ͵ĶÔÏó¶¼ÐèҪĬÈϼ̳ÐObject¶ÔÏó£¬Òò´Ë²»ÂÛʲôÑùµÄJava¶ÔÏó£¬Æä´óС¶¼±ØÐëÊÇ´óÓÚ8byte¡£ ÓÐÁËObject¶ÔÏóµÄ´óС£¬ÎÒÃǾͿÉÒÔ¼ÆËãÆäËû¶ÔÏóµÄ´óСÁË¡£ Class NewObject { int count; boolean flag; Object ob; } Æä´óСΪ£º¿Õ¶ÔÏó´óС(8byte)+int´óС(4byte)+Boolean´óС(1byte)+¿ÕObjectÒýÓõĴóС(4byte)=17byte¡£µ«ÊÇÒòΪJavaÔÚ¶Ô¶ÔÏóÄÚ´æ·ÖÅäʱ¶¼ÊÇÒÔ8µÄÕûÊý±¶À´·Ö£¬Òò´Ë´óÓÚ17byteµÄ×î½Ó½ü8µÄÕûÊý±¶µÄÊÇ24£¬Òò´Ë´Ë¶ÔÏóµÄ´óСΪ24byte¡£ ÕâÀïÐèҪעÒâһϻù±¾ÀàÐ͵İü×°ÀàÐ͵ĴóС¡£ÒòΪÕâÖÖ°ü×°ÀàÐÍÒѾ­³ÉΪ¶ÔÏóÁË£¬Òò´ËÐèÒª°ÑËûÃÇ×÷Ϊ¶ÔÏóÀ´¿´´ý¡£°ü×°ÀàÐ͵ĴóСÖÁÉÙÊÇ12byte(ÉùÃ÷Ò»¸ö¿ÕObjectÖÁÉÙÐèÒªµÄ¿Õ¼ä)£¬¶øÇÒ12byteûÓаüº¬ÈκÎÓÐЧÐÅÏ¢£¬Í¬Ê±£¬ÒòΪJava¶ÔÏó´óСÊÇ8µÄÕûÊý±¶£¬Òò´ËÒ»¸ö»ù±¾ÀàÐÍ°ü×°ÀàµÄ´óСÖÁÉÙÊÇ16byte¡£Õâ¸öÄÚ´æÕ¼ÓÃÊǺֲܿÀµÄ£¬ËüÊÇʹÓûù±¾ÀàÐ͵ÄN±¶(N>2)£¬ÓÐЩÀàÐ͵ÄÄÚ´æÕ¼ÓøüÊÇ¿äÕÅ(Ëæ±ãÏëϾÍÖªµÀÁË)¡£Òò´Ë£¬¿ÉÄܵĻ°Ó¦¾¡Á¿ÉÙʹÓðü×°Àà¡£ÔÚJDK5.0ÒÔºó£¬ÒòΪ¼ÓÈëÁË×Ô¶¯ÀàÐÍ×°»»£¬Òò´Ë£¬JavaÐéÄâ»ú»áÔÚ´æ´¢·½Ãæ½øÐÐÏàÓ¦µÄÓÅ»¯¡£ ÒýÓÃÀàÐÍ ¶ÔÏóÒýÓÃÀàÐÍ·ÖΪǿÒýÓá¢ÈíÒýÓá¢ÈõÒýÓúÍÐéÒýÓᣠǿÒýÓÃ:¾ÍÊÇÎÒÃÇÒ»°ãÉùÃ÷¶ÔÏóÊÇʱÐéÄâ»úÉú³ÉµÄÒýÓã¬Ç¿ÒýÓû·¾³Ï£¬À¬»ø»ØÊÕʱÐèÒªÑϸñÅжϵ±Ç°¶ÔÏóÊÇ·ñ±»Ç¿ÒýÓã¬Èç¹û±»Ç¿ÒýÓã¬Ôò²»»á±»À¬»ø»ØÊÕ ÈíÒýÓÃ:ÈíÒýÓÃÒ»°ã±»×öΪ»º´æÀ´Ê¹Óá£ÓëÇ¿ÒýÓõÄÇø±ðÊÇ£¬ÈíÒýÓÃÔÚÀ¬»ø»ØÊÕʱ£¬ÐéÄâ»ú»á¸ù¾Ýµ±Ç°ÏµÍ³µÄÊ£ÓàÄÚ´æÀ´¾ö¶¨ÊÇ·ñ¶ÔÈíÒýÓýøÐлØÊÕ¡£Èç¹ûÊ£ÓàÄÚ´æ±È½Ï½ôÕÅ£¬ÔòÐéÄâ»ú»á»ØÊÕÈíÒýÓÃËùÒýÓõĿռä;Èç¹ûÊ£ÓàÄÚ´æÏà¶Ô¸»Ô££¬Ôò²»»á½øÐлØÊÕ¡£»»¾ä»°Ëµ£¬ÐéÄâ»úÔÚ·¢ÉúOutOfMemoryʱ£¬¿Ï¶¨ÊÇûÓÐÈíÒýÓôæÔڵġ£ ÈõÒýÓÃ:ÈõÒýÓÃÓëÈíÒýÓÃÀàËÆ£¬¶¼ÊÇ×÷Ϊ»º´æÀ´Ê¹Óᣵ«ÓëÈíÒýÓò»Í


Ïà¹ØÎĵµ£º

Java¿ª·¢ºËÐļ¼ÊõÃæÊÔÐĵ÷ÖÎö

JavaµÄÊý¾Ý½á¹¹ÓÐÄÄЩ£¿MapÓëSetµÄ±¾ÖÊÇø±ðÊÇʲô£¿
·ÖÎö£ºJava³£¼ûµÄÊý¾Ý½á¹¹ÓÐCollectionºÍMap£¬ÆäÖÐCollection½Ó¿ÚÏ°üÀ¨ListºÍSet½Ó¿Ú£¬ÆäÏÂÓÖÓжà¸öʵÏÖÀàÈçListÏÂÓÐArrayList¡¢LinkedListºÍVectorµÈʵÏÖÀ࣬SetÏÂÓÐHashSet¡¢LinkedSetµÈʵÏÖÀàºÍSortedSet½Ó¿Ú£¬HashSetÏÂÓÐLinkedHashSet×ÓÀ࣬SortedSet½Ó¿ÚÏÂÓÐTre ......

ÈçºÎѸËÙ³ÉΪJava¸ßÊÖ

ÒªÏëѧºÃJava£¬Ê×ÏÈÒªÖªµÀJavaµÄ´óÖ·ÖÀà¡£ÎÒÃÇÖªµÀ£¬×Ô´ÓSunÍƳöJavaÒÔÀ´£¬¾ÍÁ¦Í¼Ê¹Ö®ÎÞËù²»°ü£¬ËùÒÔJava·¢Õ¹µ½ÏÖÔÚ£¬°´Ó¦ÓÃÀ´·ÖÖ÷Òª ·ÖΪÈý´ó¿é£ºJ2SE,J2MEºÍ J2EE,ÕâÒ²¾ÍÊÇSun ONE(Open Net Environment)Ìåϵ¡£J2SE¾ÍÊÇJava2µÄ±ê×¼°æ£¬Ö÷ÒªÓÃÓÚ×ÀÃæÓ¦ÓÃÈí¼þµÄ±à³Ì£»J2MEÖ÷ÒªÓ¦ÓÃÓÚǶÈëÊÇϵͳ¿ª·¢£¬ÈçÊÖ»úºÍPDAµÄ±à ³Ì£» ......

java ³õѧÕß µÚ¶þ¸öÎÊÌâ

1.н¨Ò»¸öservlet³ÌÐò£¬ÎļþÃûΪTest.java£¬ÎļþÄÚÈÝÈçÏ£º
package test;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServle ......

Ò»µÀjavaÌâËù½ÒʾµÄÔ­Àí

¿´µ½Ò»µÀjavaÌ⣬¸Ð¾õºÜ²»´í,ÎÒÔÚÔ­À´µÄ°æ±¾ÉÏÔö¼ÓÁËЩ´úÂ룬һÆðÀ´¿´¿´ÏÂÃæµÄ´úÂ뽫Êä³öʲô
class Father{
int i,j;

Father(){
add(1);
}
void add(int v){
i+=v;
j+=v;
}
void print(){
System.out.println("i:="+i);
System.out.println("j:="+j);
}
}
class C ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ