开发者

How to retrieve java process & perform GC based on the java process memory?

I am interested to retrieve the java process from the task manager & perform开发者_如何学C GC based on the memory...

Can you provide any information to achieve it

Thanks & regards, Krishna


Here is a description on how to get the current used memory:

http://viralpatel.net/blogs/2009/05/getting-jvm-heap-size-used-memory-total-memory-using-java-runtime.html

The Garbage Collector you can trigger by calling:

System.gc()

see: http://download.oracle.com/javase/1.4.2/docs/api/java/lang/System.html#gc%28%29 For a documentation


As far as I understand you wish to perform these operations on external process (retrieve the java process from the task manager).

I'd suggest you to check out JMX. This is the "normal" way to do it remotely. If JConsole does it you can implement it yourself too.

You have to use java.lang.management.GarbageCollectorMXBean

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜