Sagewire Logo

Memory leak in JAVA app

8 Message(s) by 6 Author(s) originally posted in java programmer


From: amorgan Date:   Thursday, October 25, 2007
I have a JAVA app , run ning on Windows , with a medium amount
of C++ wrapper code doing various arcane and boring things.
JProfiler swears that there is not a memory leak in the JAVA.
Purify claims that there is not 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 does not
make much of a difference (the amount of memory used goes down ,
but the increase remains). I have not 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 expect ed behavior? Is the only solution to kill and
resume the app on a regular basis?

Alan
--
Defendit numerus


From: amorgan Date:   Thursday, October 25, 2007
In article <I_idnSdha7zskLzanZ2dnUVZ_hWdnZ2d@xxxxxxxxxxx>,
wrote in message:
wrote in message:
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 is not a memory leak in the JAVA.
Purify claims that there is not a memory leak in the C++. According
to ProcessExplorer, however, we leak memory (or rather, the
Private Byte and Working Set keep rising).
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 process es memory consumption
>does not tell you what is actually in use. The garbage collector usually
>does not try very hard until the used memory gets to be very close to
"full" for the currently allocated heap size.



I'm aware of that, but there may be some subtlties in the JAVA GC that
I'm missing. JProfiler claims that the heap never grows beyound about
10MB. I see regular garbage collections occurring which generally reduce
my consumption from about 9MB to about 6MB. I can run the system all day
and this won't change. However, Process Explorer insists that my app,
which started off using 30MB of private memory, is now using 60MB. Forcing
a GC via JProfiler does not do anything to change this.

Obviously using JProfiler is going change the system behavior and mess
with these numbers blah blah Heisenberg. I realize this isn't an exact
science.

Alan
--
Defendit numerus


From: amorgan Date:   Thursday, October 25, 2007
In article <3Q9Ui.2598$Nz7.1118@xxxxxxxxxxx>,
wrote in message:
wrote in message:
and this won't change. However, Process Explorer insists that my app,
which started off using 30MB of private memory, is now using 60MB. Forcing
a GC via JProfiler does not do anything to change this.

Obviously using JProfiler is going change the system behavior and mess
with these numbers blah blah Heisenberg. I realize this isn't an exact
science.
Roedy's link explains that not calling dispose() on GUI objects results
in the underlying (native) objects being retained by the OS.



Mmm. I'm not using GUI objects but the same principles could apply to
other objects. I will see if Purity can give me any information there.

Alan
--
Defendit numerus


From: Daniel Pitts Date:   Thursday, October 25, 2007
wrote in message:
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 is not a memory leak in the JAVA.
Purify claims that there is not 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 does not
make much of a difference (the amount of memory used goes down,
but the increase remains). I have not 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
does not tell you what is actually in use. The garbage collector usually
does not 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/>


From: Roedy Green Date:   Thursday, October 25, 2007
On Thu, 25 Oct 2007 14:06:03 -0700 (PDT), amorgan@xxxxxxxxxxx
wrote in message, quoted or indirectly quoted someone who said :

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 is not a memory leak in the JAVA.
Purify claims that there is not a memory leak in the C++



but you may have some packratting. See
http://mindprod.com/jgloss/packratting.html
--
Roedy Green Canadian Mind Products
The JAVA Glossary
http://mindprod.com


From: Mark Space Date:   Thursday, October 25, 2007
wrote in message:

and this won't change. However, Process Explorer insists that my app,
which started off using 30MB of private memory, is now using 60MB. Forcing
a GC via JProfiler does not do anything to change this.
Obviously using JProfiler is going change the system behavior and mess
with these numbers blah blah Heisenberg. I realize this isn't an exact
science.



Roedy's link explains that not calling dispose() on GUI objects results
in the underlying (native) objects being retained by the OS. Could be
something like that. You may have to look beyond the JVM and see what
the rest of the system is allocating on your behalf.

I'm not an expert in Windows heap analysis by any means, but if you find
some good info debugging Windows heaps please post up what you find. :-)


From: Robert Klemme Date:   Friday, October 26, 2007
wrote in message:
In article <3Q9Ui.2598$Nz7.1118@xxxxxxxxxxx>,
wrote in message:
wrote in message:

and this won't change. However, Process Explorer insists that my app,
which started off using 30MB of private memory, is now using 60MB. Forcing
a GC via JProfiler does not do anything to change this.
Obviously using JProfiler is going change the system behavior and mess
with these numbers blah blah Heisenberg. I realize this isn't an exact
science.
Roedy's link explains that not calling dispose() on GUI objects results
in the underlying (native) objects being retained by the OS.
Mmm. I'm not using GUI objects but the same principles could apply to
other objects. I will see if Purity can give me any information there.



Did you run the JVM with verbose GC trace? Did it tell anything
interesting?

Btw, 60MB doesn't sound much nowadays. I believe the JVM's default for
-Xmx is 64MB so you could expect it to grow a bit more without having
to worry.

Kind regards

robert


From: kohlerm Date:   Friday, October 26, 2007
wrote in message:
In article <I_idnSdha7zskLzanZ2dnUVZ_hWdn...@xxxxxxxxxxx>,
wrote in message:
wrote in message:
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 is not a memory leak in the JAVA.
Purify claims that there is not a memory leak in the C++. According
to ProcessExplorer, however, we leak memory (or rather, the
Private Byte and Working Set keep rising).
>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
>does not tell you what is actually in use. The garbage collector usually
>does not try very hard until the used memory gets to be very close to
>"full" for the currently allocated heap size.
I'm aware of that, but there may be some subtlties in the JAVA GC that
I'm missing. JProfiler claims that the heap never grows beyound about
10MB. I see regular garbage collections occurring which generally reduce
my consumption from about 9MB to about 6MB. I can run the system all day
and this won't change. However, Process Explorer insists that my app,
which started off using 30MB of private memory, is now using 60MB. Forcing
a GC via JProfiler does not do anything to change this.
Obviously using JProfiler is going change the system behavior and mess
with these numbers blah blah Heisenberg. I realize this isn't an exact
science.
Alan
--
Defendit numerus



This looks like that the leak isn't in JAVA.
To be sure the easiest way to find out whether it's a leak in JAVA is
to get
the SAP Memory Analyzer at https://www.sdn.sap.com/irj/sdn/wiki?path=/display/JAVA/JAVA+Memory+Analysis.
It's free and will be open sourced soon(check my blog here
https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/7637)

Regards,
Markus



Next Message: Wait Cursor stuck in Table Header, bug??


Blogs related to Memory leak in JAVA app

Re: Native Library Not found
I have a 2GB memory. I have added a connection pool using commons-dbcp and thought that will reduce the probs. What is your suggestion. As I told there is a scheduler running on every minute. Looks like I have some memory leak. ...

Crawling sucks.
Threading - I over-designed the threaded application without investing enough time to understand how threading works in java. That, with a few caching features I created became the memory leak I so much wanted to avoid. ...

JAVA BY MOHIT
When no references to an object remain, the Java garbage collector automatically deletes the unreachable object, freeing memory and preventing a memory leak. Memory leaks may still occur if a programmer's code holds a reference to an ...

Advanced Windows Debugging
Mario Hewardt and Daniel Pravat cover debugging throughout the entire application lifecycle and show how to make the most of the tools currently available—-including Microsoft’s powerful native debuggers and third-party solutions. ...

java medical
java mediaplayer java mediator pattern java medical java meeting java memento java memento pattern java memory java memory allocation java memory command line java memory debugger java memory game java memory game code java memory game ...

Java Memory leaks
It is hard to identify if your Java application has memory leaks by simply looking at the code as they show up only in runtime. The hint of a memory leak is the java.lang.OutOfMemoryError (This does not necessarily mean a memory leak, ...


Programming | Sports | Autos

copyright 2006
Valid XHTML 1.0 Transitional