How to print Java class garbage collection events?

java version "1.5.0_14"
java version "1.5.0_14"
Java(TM) 2 Runtime Environment,Standard Edition (build 1.5.0_14-b03)
Java HotSpot(TM) Server VM (build 1.5.0_14-b03,mixed mode)

I tried to debug a NullPointerException and I got to pass a reference to a statically defined field More specifically, I set the global on the drools 3 working memory instance

workingMemory.setGlobal("log",workingMemorieslog);

My assumption is that the class that statically defines the field is garbage collection (the receiving class must use WeakReference or something similar. I really don't know)

How would you suggest debugging this? I think if I can know exactly how the GC of the JVM unloads the class / instance of a class, then I can narrow down the cause of the wrong behavior (if not the exact time of the event, at least there are signs that something has happened)

Thank you, Maxim

Solution

To track GC activity, add it to the Java command:

The NPE you get may be the null value you pass

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>