Some kind of slow leak?

T

Twisted

I have a Java app I'm developing here that seems to have developed a
slow leak.

It spawns around 100 threads, which do various things with some shared
resources (mainly collections); the resources are locked (in a fixed
order) before use, so this shouldn't be a concurrency issue. These
collections are periodically either wiped or halved in size, when they
grow to certain sizes, so that they cannot cause the memory use of the
app to grow without bound.

Yet grow it does; the task eventually bloats up to 90+ meg and when it
gets to that size, it becomes slow and unstable. Then I start getting
crashes. Best case, weird exceptions or OutOfMemoryErrors (when there's
still 3/4 of the machine's physical RAM free!) pop up and it tries to
exit gracefully. Or it lurches to a halt (hangs, possibly taking the
IDE down with it if its debugger is attached to the process), or it
outright crashes (sigsegv in Hotspot VM).

Anyone have an idea what's happening here? Lots of objects are created
transiently and discarded -- is it possible the system GC isn't able to
keep up with the rate at which this occurs? (Translation: use less
threads, even if it means the app spends more time idling and less
accomplishing something useful.) Or is there a way that things might be
hanging around, and cruft slowly accumulating in memory that isn't
getting swept away? (Possibly a library call that uses a native method?
Native methods written in C could leak easily, unlike Java code.) Or
perhaps attaching a debugger is itself causing the bloat? (Objects the
debugger notices may hang around because the debugger hangs onto
references, which stop them being gc'd?)

JDK and JRE version 1.5.0_06.
 
J

josh.s17

Have you tried increasing the heap size of the JVM. Just because you
have available memory on the machine doesn't mean it will automatically
be available to your process.
 
T

Twisted

??

Anyway, I'd prefer to actually fix its mem use not to be so excessive.
Nothing it does requires even 90-odd megs...
 
J

josh.s17

Perhaps someone who suggest a profiling tool to use? Without looking
thought source it is hard to offer any other suggestions.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top