[Change] memory leak using jdk6 check (see the preparation of the GC-friendly and does not leak Code)

Memory leak using jdk6 check (see the preparation of the GC-friendly and does not leak code)
(1) jmap-dump: file = heap_file_name pid file will produce a heap_file_name
(2) jhat heap_file_name, and then open the browser http://localhost:7000/ browsing.
Can see which shows are running all the classes and instances, and size. Platform (such as tomcat) to not be included in it.
(3) If that is not enough, you can also add a bin to heap_file_name file suffix, and then let Eclipse MAT to analyze. See here.
jps: with unix on ps similar to the process used to display the local java, you can see a few local running java process, and demonstrate their process ID.
jinfo: the usefulness of relatively simple, is able to output and modify the java run-time process operating parameters. Usage is jinfo-opt pid, such as: View 2788's MaxPerm size can jinfo-flag MaxPermSize 2788.
jstat also useful to illustrate see here

SUN JDK that is supported by the typical options and instructions: http://java.sun.com/javase/technologies/hotspot/vmoptions.jsp with lots of options
-XX:-HeapDumpOnOutOfMemoryError From jdk1.4.2 update 12 and java 5 update 7 began to support this option.

About jmap
JDK 5 from the start, SUN JDK began offering JMap tool. But the only experimental, and only in the solaris platform there.
Later Jmap be back ported to jdk 1.4.2_09. Because it is experimental, so jmap dump may occur in case of failure.
However, since JDK 6 after, jmap stability and usability have no problems. Please note that each version of the jvm should use their own version of the jmap,
The jhat can be used to analyze the various versions of jmap dump out the file. As jhat for the analysis of more than 1g dump file
We have had numerous success stories in a notebook, its memory requirements may not be that high.

5, J2SE6 jhat used to analyze the memory heap

6, Java out of memory (OutOfMemory), memory analysis tools

7, JDK in a good tool jmap, jhat

8, SAP contribution to the eclipse foundation MemoryAnalyzer, originally called the Java Memory Analysis
To analyze a few G's Memory Dump of memory instead?
Unfortunately, or just support jdk1.4.2 update 12 and java 5 update 7 or more

9, in a way which the variable is not cause memory leaks.
Memory leak occurred in the class variables and instance variables (and this instance is cached, such as the single case of mode) in.
I suggest you from HashMap, HashMap $ Entry start look up.
I have looked for a while the memory leak problem, finally solved.

10, you encounter is the ideal situation, but sometimes, this method can not find the reason, only to find the point of causing collapse.'s Like,
An HTTP request, there is no set time-out (sorry, the default is no timeout, did not know why SUN to this set),
Then this thread on the card in here, then, this thread in a stack is placed in another thread content
Originally, the content is to idle threads to handle this, but now, this thread is stuck, but with this method you said,
Absolutely can not find the cause of memory leaks because http does not time out, there have been cards.

I have done a fine Ben Banfa more memory allocation: to dump out regularly with pmap command JVM process memory mapping table, and then diff.

11, http://calvin.javaeye.com/blog/91903
java garbage collector is not it? How has a leak, ah, Hu I ah? ?
Ah, the ratio of leakage of non-leakage. C / C + + to leak, the object has not arrived, but no recovery of memory, real memory black hole.
The Java leakage is due to various reasons, object to the application have been useless, but it has been held, has been accessible.
Because nothing less than the sum of several aspects:

1). Was a very long life cycle of collections held improper claims to be the first for Java memory leak.
These collection classes De life cycles usually last very long, and is an auxiliary regulatory nature object, the transaction runs a Yewu After that, if not an object Zhu Dong Ye Wu's removal from the case, the set Jiuhui eat Yuelai Yue and more memory can be used WeakReference, such as WeakHashMap, making it the object holding the object reference does not increase the number.
2). Scope not defined, this is very simple, method local variables defined as class variables, class static variable so.
3). Exception did not increase finally () to release some resources, JDBC time is also very common thing.
4). I have deep understanding of other reasons, such as: Swing in the Listener does not explicitly remove; inner class holds an implicit reference to external objects; Finalizers associated object is not caused by empty and so timely.

分类:Java 时间:2010-05-05 人气:239
blog comments powered by Disqus


iOS 开发

Android 开发

Python 开发



PHP 开发

Ruby 开发






Javascript 开发

.NET 开发



Copyright (C) codeweblog.com, All Rights Reserved.

CodeWeblog.com 版权所有 闽ICP备15018612号

processed in 0.499 (s). 10 q(s)