Re: Memory leak in Java app
Alan Morgan wrote:
I have a Java app, running on Windows, with a medium amount
of C++ wrapper code doing various arcane and boring things.
JProfiler swears that there isn't a memory leak in the Java.
Purify claims that there isn't a memory leak in the C++. According
to ProcessExplorer, however, we leak memory (or rather, the
Private Byte and Working Set keep rising). Some of this might
be induced by memory fragmentation, I suppose, but other than
that and the thought that Sun's JVM might leak memory (possible?),
I'm not sure where to go.
I'm currently using Sun's 1.5 JVM. Client and Server mode doesn't
make much of a difference (the amount of memory used goes down,
but the increase remains). I haven't tested extensively with 1.6,
but saw essentially the same behavior with my quick look.
Is futzing with the GC parameters going to accomplish anything?
Is this just expected behavior? Is the only solution to kill and
resume the app on a regular basis?
Alan
Only assume you're leaking memory if over a sufficient time period, you
get OOM exceptions. Java is a Garbage Collected environment, which
means that some objects may just hang around until the GC decides its
time to clean them up. Looking at the java processes memory consumption
doesn't tell you what is actually in use. The garbage collector usually
doesn't try very hard until the used memory gets to be very close to
"full" for the currently allocated heap size.
In other words, its normal to have memory usage creep up slowly and
then, with no warning or explanation, drop down to normal levels again.
--
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>