assuming i have a class 'Document' in a multiple document
application. now when the document is closed and disposed, i want
to find out if there are any left over references to that instance
of Document, since i seem to have a memory leak here and the
document or parts of it don't find there way into garbage
collection (at least that's my theory, as after opening + closing
documents for a while, at some point i get OutOfMemoryErrors).
references can be complex (let's say for example ElementA of List1
of ElementB of List2 is still in the clipboard and List2 has a
reference to the disposed document; or i made copies from elements
that accidentially have references to the original object; or some
element of the doc was stored in a static collection somewhere
etc.), so are there any automatic ways for determining this
(getting a list of references to object 'myDoc')?
Profile it would be one.
Given...
public class DocumentTester {
public static void main(String[] args) {
for (int i=0;i<100;i++)
new DocumentTester();
}
}
doing....
java -agentlib:hprof=heap=sites DocumentTester
and then looking at the resulting (on exit or sending a signal -QUIT)
java.hprof.txt file and going to...
SITES BEGIN (ordered by live bytes) Wed Aug 30 08:22:11 2006
percent live alloc'ed stack class
rank self accum bytes objs bytes objs trace name
1 20.32% 20.32% 70880 25 70880 25 300087 byte[]
2 9.40% 29.72% 32800 2 82000 5 300127 char[]
3 4.71% 34.43% 16416 2 41040 5 300124 byte[]
...
36 0.23% 58.05% 800 100 800 100 300411 DocumentTester
Shows that for this simple test the DocumentTester is not a memory
problem being only 36th in memory usage and less than a 1/4 of one
percent.
Still there are a hundred of them. Where did they come from? My own
memory not being what it used to be I search on '300124' to find the
trace.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden
This email sent to email@hidden