views:

43

answers:

3

I am currently trying to determine the cause of high memory usage in a Java application running on an exotic platform where I know of no instrumented JVM.

I have the source to the application, and can make changes to the source for the purposes of testing.

How can I debug memory usage under these conditions?

If more info is needed, I'll be happy to provide. I'm just a little lost trying to use such an old jvm without much tooling to speak of.

+2  A: 

If I were in your shoes I would approach it with:

  1. Find the functional areas you know need attention.
  2. Make backup copy of code
  3. Start inserting print statements with start and end times
  4. See what takes a lot of time and narrow it down.
Romain Hippeau
A: 

For Java 5 and later this can be done using Java agents. For earlier versions - including 1.1.8 - you must load native agents to do this. If you cannot instrument your code, you must do the work needed yourself.

One approach to get most of the way is to use a Java 1.1 compatible version of log4j which allows you to essentially write out strings prepended with a timestamp. This can then be massaged afterwards into extracting answers to whatever you want to know.

Thorbjørn Ravn Andersen
A: 

If you need memory profiling - and I'd recommend against this - you could start serializing objects out to disk, then measuring disk size as a rough estimate of memory size.

If you really want to dig into where you're usually not supposed to be, try the sun.misc package, although I don't know how much of that was around in 1.1.x.

Dean J