API w/ mem usage trigger

Questions about YourKit Java Profiler
Post Reply
eoliphan
Posts: 3
Joined: Wed Jan 12, 2005 7:36 pm

API w/ mem usage trigger

Post by eoliphan »

Hi,
I've been playing with your product (very impressive esp. considering the price point).

I am interested in using it to track down a 'runaway' memory leak that we've been dealing with. Basically, our app runs normally most of the time but every so often goes nuts and starts allocating memory like crazy. Since this is a rare occurence, using the console to turn on tracing is not an option. I'd like to use the API to start tracing object allocations and taking periodic snapshots after a certain memory threshold is reached.

I was wondering if you guys had any suggestions regarding getting the JVM's memory usage remotely (i.e. something like calling Runtime.freeMemory() from outside the JVM). Our app is heavily used so I don't think periodically requesting a MemorySnapshot is viable. I looked at the Java Debug Interface but there's no functions to support this.

Thanks
Vladimir Kondratyev
Posts: 1624
Joined: Tue Aug 10, 2004 7:52 pm

Post by Vladimir Kondratyev »

There is an open API that allows to take memory or CPU snapshot programmatically. Please take a look at bundled samples at $YJP_HOME/samples.

Just a hint: your app should periodically check its own memory usage (for example, Runtime.freeMemory()) and capture snapshot when it's required.

To use this API you only need small "redist" JAR; and it doesn't require any installed license. Also API allows to turn allocation recording, etc.
eoliphan
Posts: 3
Joined: Wed Jan 12, 2005 7:36 pm

Post by eoliphan »

Right, I understand the ability to take snapshots. What I am trying to figure out is how to check the freeMemory() in the remote JVM. Since the app that uses the YourKit api would be in a separate process (I guess I could run it in the same JVM but then it's monitoring,etc ability might be adversely affected by condition I am trying to diagnose), calling freeMemory locally will not help.
Vladimir Kondratyev
Posts: 1624
Joined: Tue Aug 10, 2004 7:52 pm

Post by Vladimir Kondratyev »

I am trying to figure out is how to check the freeMemory() in the remote JVM
Currently there is no an API to check memory usage of remote JVM. That's why I'm suggesting you to implement "monitoring thread" just inside your application. It's quite trivial code (not more then 10 lines) and such monitoring doesn't cosume any CPU or memory resources.
Post Reply