save jvm by yourself: real war experiences of oom

Post on 07-Apr-2017

728 Views

Category:

Software

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

#JCConf

••

••••••

••

••••

#JCConf

https://www.youtube.com/watch?v=450maTzSIvA

13

#JCConf

•–

••

–•

•–

A B

C

D E

F G

H

AandBaregarbagecollectionroots,(GCroots)

LeadingSet RetainedSetE E,GC C,D,E,F,G,HA,B A,B,C,D,E,F,G,H

A B

C

D E

F G

H

A B

C

D E

F G

H

A B

C

D E

F G

H

A B

C

D E

F G

H

#JCConf

Done

More Things…

Listobjects→withoutgoingreferences

oracle.jdbc.ScrollableResultSet →scrollStmt→sqlObject →sqlBytes →Copy→Value

SELECT*FROMPOP.PRMASTER,POP.PRITEM WHERE…………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………..……………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………Order ByPRITEM.IDOCNUMBERDESC,PRITEM.ITEM

MergeShortes PathstoGCRoots→excludeallphantom/weak/softetc.references

Listobjects→withoutgoingreferences

SortingbyClassName

java.lang.Thread→org.apache.catlina.connector.Request→postData →Copy→Value

sessionid=16F098C27D8DE1C8C7E58A15798C470A&applicantID=&hcreatorID=&applicantName …………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………..…………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………… KOLON_prodhier=K0

HTTPRequestAttributesorg.apache.catlina.connector.Request→attributes→table→java.util.HashMap$Entry

HTTPSessionDataorg.apache.catlina.connector.Request→session→attributes→segments→java.util.concurrent.ConcurrentHashMap$Segment

JavaBasics→ThreadOverviewandStacks

••

••

••

#JCConf

•–

•–

MergeShortestPathstoGCRoots→excludeallphantom/weak/softetc.references

Listobjects→withoutgoingreferences

Expandthenode

targetorg.apache.logging.log4j.core.util.DefaultShutdownCallbackRegistry

Using Log4j 2 in Web ApplicationsYou must take particular care when using Log4j or any other logging framework within a Java EE web application. It's important for logging resources to be properly cleaned up (database connections closed, files closed, etc.) when the container shuts down or the web application is undeployed. Because of the nature of class loaders within web applications, Log4j resources cannot be cleaned up through normal means. Log4j must be "started" when the web application deploys and "shut down"when the web application undeploys. How this works varies depending on whether your application is a Servlet 3.0 or newer or Servlet 2.5 web application.In either case, you'll need to add the log4j-webmodule to your deployment as detailed in the Maven, Ivy, and Gradle Artifacts manual page.

To avoid problems the Log4j shutdown hook will automatically be disabled when the log4j-web jar is included.

<classloader>org.apache.logging.log4j.core.jmx.StatusLoggerAdminMBean

•–

•–

#JCConf

••••

/* */ public abstract class ItemFactory/* */ implements Constants/* */ {/* */ protected static Logger a;/* 45 */ public Map b = null;/* */ public static int c;/* */ private static String[] A;/* *//* */ protected ItemFactory()/* */ {/* 51 */ this.b = Collections.synchronizedMap(new HashMap());/* 52 */ if ((ItemBean.d) || (a == null)) {/* 53 */ a = Logger.getLogger(A[2]);/* */ }/* */ }

Badnews:Itisobfuscated(混淆)Can’tdecompile,rewrite,andcompile…

•public aspect ItemFactoryAop {

private final static int DEFAULT_CACHE_SIZE = 100000;

after() : execution(workflow.ItemFactory.new()) {

((ItemFactory)thisJoinPoint.getThis()).b = Collections.synchronizedMap(

new cache.LruCache(DEFAULT_CACHE_SIZE));

}}

•–

•–

#JCConf

•••••

•–

#JCConf

•••

#JCConf

May Your JVMLive Long and Prosper

top related