JAVAÄÚ´æÒç³ö½âÎö
ÔÒòÓкܶàÖÖ£¬±ÈÈ磺
1.Êý¾ÝÁ¿¹ýÓÚÅÓ´ó£»ËÀÑ»·
£»¾²Ì¬±äÁ¿ºÍ¾²Ì¬·½·¨¹ý¶à£»µÝ¹é£»ÎÞ·¨È·¶¨ÊÇ·ñ±»ÒýÓõĶÔÏó£»
2.ÐéÄâ»ú²»»ØÊÕÄڴ棨ÄÚ´æй©£©£»
˵°×Á˾ÍÊdzÌÐòÔËÐÐÒªÓõ½µÄÄÚ´æ´óÓÚÐéÄâ»úÄÜÌṩµÄ×î´óÄÚ´æ¾Í·¢ÉúÄÚ´æÒç³öÁË¡£
ÄÚ´æÒç³öµÄÎÊÌâÒª¿´ÒµÎñºÍϵͳ´óС¶ø¶¨£¬¶ÔÓÚijЩϵͳ¿ÉÄÜÄÚ´æÒç³ö²»³£¼û£¬µ«Ä³Ð©ÏµÍ³»¹ÊǺܳ£¼ûµÄ½â¾öµÄ·½·¨£¬
Ò»¸öÊÇÓÅ»¯³ÌÐò´úÂ룬Èç¹ûÒµÎñÅÓ´ó£¬Âß¼¸´ÔÓ£¬¾¡Á¿¼õÉÙÈ«¾Ö±äÁ¿µÄÒýÓã¬ÈóÌÐòʹÓÃÍê±äÁ¿µÄʱºòÊͷŸÃÒýÓÃÄܹ»ÈÃÀ¬»ø»ØÊÕÆ÷»ØÊÕ£¬ÊÍ·Å×ÊÔ´¡£
¶þ¾ÍÊÇÎïÀí½â¾ö£¬Ôö´óÎïÀíÄڴ棬Ȼºóͨ¹ý£º-Xms256m
-Xmx256m -XX:MaxNewSize=256m -XX:MaxPermSize=256mµÄÐÞ¸Ä
Ò»¡¢ÄÚ´æÒç³öÀàÐÍ
1
¡¢ java.lang.OutOfMemoryError: PermGen space
JVM
¹ÜÀíÁ½ÖÖÀàÐ͵ÄÄڴ棬¶ÑºÍ·Ç¶Ñ¡£¶ÑÊǸø¿ª·¢ÈËÔ±ÓõÄÉÏÃæ˵µÄ¾ÍÊÇ£¬ÊÇÔÚ JVM Æô¶¯Ê±´´½¨£»·Ç¶ÑÊÇÁô¸ø JVM ×Ô¼ºÓõģ¬ÓÃÀ´´æ·ÅÀàµÄÐÅÏ¢µÄ¡£ËüºÍ¶Ñ²»Í¬£¬ÔËÐÐÆÚÄÚ
GC ²»»áÊͷſռ䡣Èç¹û web app ÓÃÁË´óÁ¿µÄµÚÈý·½ jar »òÕßÓ¦ÓÃÓÐÌ«¶àµÄ class Îļþ¶øÇ¡ºÃ MaxPermSize
ÉèÖýÏС£¬³¬³öÁËÒ²»áµ¼ÖÂÕâ¿éÄÚ´æµÄÕ¼Óùý¶àÔì³ÉÒç³ö£¬»òÕß tomcat ÈȲ¿Êðʱºî²»»áÇåÀíÇ°Ãæ¼ÓÔصĻ·¾³£¬Ö»»á½« context
¸ü¸ÄΪв¿ÊðµÄ£¬·Ç¶Ñ´æµÄÄÚÈݾͻáÔ½À´Ô½¶à¡£
2
¡¢ java.lang.OutOfMemoryError: Java heap space
µÚÒ»ÖÖÇé¿öÊǸö²¹³ä£¬Ö÷Òª´æÔÚÎÊÌâ¾ÍÊdzöÏÖÔÚÕâ¸öÇé¿öÖС£ÆäĬÈÏ¿Õ¼ä
( ¼´ -Xms) ÊÇÎïÀíÄÚ´æµÄ 1/64 £¬×î´ó¿Õ¼ä (-Xmx) ÊÇÎïÀíÄÚ´æµÄ 1/4 ¡£Èç¹ûÄÚ´æÊ£Ó಻µ½ 40 £¥£¬ JVM ¾Í»áÔö´ó¶Ñµ½ Xmx
ÉèÖõÄÖµ£¬ÄÚ´æÊ£Ó೬¹ý 70 £¥£¬ JVM ¾Í»á¼õС¶Ñµ½ Xms ÉèÖõÄÖµ¡£ËùÒÔ·þÎñÆ÷µÄ Xmx ºÍ Xms ÉèÖÃÒ»°ãÓ¦¸ÃÉèÖÃÏàͬ±ÜÃâÿ´Î GC
ºó¶¼Òªµ÷ÕûÐéÄâ»ú¶ÑµÄ´óС¡£¼ÙÉèÎïÀíÄÚ´æÎÞÏÞ´ó£¬ÄÇô JVM ÄÚ´æµÄ×î´óÖµ¸ú²Ù×÷ϵͳÓйأ¬Ò»°ã 32 λ»úÊÇ 1.5g µ½ 3g Ö®¼ä£¬¶ø 64
λµÄ¾Í²»»áÓÐÏÞÖÆÁË¡£
×¢Ò⣺Èç¹û
Xms ³¬¹ýÁË Xmx Öµ£¬»òÕ߶Ñ×î´óÖµºÍ·Ç¶Ñ×î´óÖµµÄ×ܺͳ¬¹ýÁËÎïÀíÄÚ´æ»òÕß²Ù×÷ϵͳµÄ×î´óÏÞÖƶ¼»áÒýÆð·þÎñÆ÷Æô¶¯²»ÆðÀ´¡£
À¬»ø»ØÊÕ
GC µÄ½ÇÉ«
JVM
µ÷Óà GC µÄƵ¶È»¹ÊǺܸߵģ¬Ö÷ÒªÁ½ÖÖÇé¿öϽøÐÐÀ¬»ø»ØÊÕ£º
µ±Ó¦ÓóÌÐòÏ߳̿ÕÏУ»ÁíÒ»¸öÊÇ
java ÄÚ´æ¶Ñ²»×ãʱ£¬»á²»¶Ïµ÷Óà GC £¬ÈôÁ¬Ðø»ØÊÕ¶¼½â¾ö²»ÁËÄÚ´æ¶Ñ²»×ãµÄÎÊÌâʱ£¬¾Í»á±¨ out of memory
´íÎó¡£ÒòΪÕâ¸öÒì³£¸ù¾ÝϵͳÔËÐл·¾³¾ö¶¨£¬ËùÒÔÎÞ·¨Ô¤ÆÚËüºÎʱ³öÏÖ¡£
¸ù¾Ý
GC
Ïà¹ØÎĵµ£º
/************Student.java begin***************/
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class Student {
private String name;
private String password;
public String getName() {
return name;
}
public ......
±¾ÏµÁÐÎÄÕÂµÄµÚ 1 ²¿·Ö½éÉÜÁË Java Card ¼¼ÊõµÄ¸ß¼¶ÖªÊ¶ —— ʲôÊÇÖÇÄÜ¿¨¡¢Java Card Ó¦ÓóÌÐòµÄÔªËØ¡¢Í¨ÐźͲ»Í¬ Java Card ¼¼Êõ¹æ·¶µÄ»ã×Ü¡£ÔÚ±¾²¿·ÖÖУ¬ÎÒÃǽ«Öصã½éÉÜ Java Card applet µÄ¿ª·¢£º¿ª·¢ Java Card Ó¦ÓóÌÐò¡¢Sun Java Card ¿ª·¢¹¤¾ßÏä¡¢Java Card ºÍ Java Card RMI API ʱËùÐèµÄÒ»°ã² ......
package test;
import javax.annotation.Resource;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.xml.ws.WebServiceContext;
import javax.xml.ws.handler.MessageContext;
@javax.jws.WebService(targetNamespace = "http://test/", serviceName = "Web ......
RMI£¨Remote Method Invocation£©
RMIÊÇ·Ö²¼Ê½¶ÔÏóÈí¼þ°ü£¬Ëü¼ò»¯ÁËÔÚ¶ą̀¼ÆËã»úÉϵÄJAVAÓ¦ÓÃÖ®¼äµÄͨÐÅ¡£
±ØÐëÔÚjdk1.1ÒÔÉÏ
RMIÓõ½µÄÀà
java.rmi.Remote ËùÓпÉÒÔ±»Ô¶³Ìµ÷ÓõĶÔÏ󶼱ØÐëʵÏָýӿÚ
java.rmi.server.UnicastRemoteObject ËùÓпÉÒÔ±»Ô¶³Ìµ÷ÓõĶÔÏ󶼱ØÐëÀ©Õ¹¸ÃÀà
ʲôÊÇRMI
Ô¶³Ì·½·¨µ÷ÓÃÊÇ ......