This discussion is archived
6 Replies Latest reply: Oct 28, 2011 1:45 PM by jschellSomeoneStoleMyAlias RSS

question on thread

AlleT Explorer
Currently Being Moderated
Hi everybody,

I have an application running on tomcat AS.

When I look at the number of threads of java process from the OS (RHEL 5, I run "ps -eLf") I get 80 entries, when I look at the number of threads through jconsole I get 35 entries.

So I guess these threads are not freed.

How can I manege this problem, which is causing a memory leak?

Thanks in advance
  • 1. Re: question on thread
    EJP Guru
    Currently Being Moderated
    I doubt that this is either a problem or a memory leak actually.
  • 2. Re: question on thread
    gimbal2 Guru
    Currently Being Moderated
    EJP wrote:
    I doubt that this is either a problem or a memory leak actually.
    Exactly that. For all you know the JVM is keeping the inactive thread handles for later use. People have fallen in the trap of comparing OS resources to JVM resources before; it just doesn't work that way.

    Try examining memory usage, you'll probably find similar discrepancies. Shocking if you keep basing decisions on guess work, but not so much shocking if you actually take the time to learn how the JVM ticks.


    And btw: Tomcat is a servlet engine, not an application server. Application servers support the full JEE specification; Tomcat does not.
  • 3. Re: question on thread
    AlleT Explorer
    Currently Being Moderated
    I don't base decision on guess work, just trying to understand.

    If I set Xmx to 760 MB and see a RSS for the java process of 2 GB, isn't that a memory leak?

    Will jvm release those handles when there will not be any physical memory available?

    If you have some pointers regarding how the jvm ticks I'd be glad to read it.

    Thanks
  • 4. Re: question on thread
    EJP Guru
    Currently Being Moderated
    You wrote:
    So I guess these threads are not freed.
    and then:
    I don't base decision on guess work, just trying to understand.
    So which is it?
    If I set Xmx to 760 MB and see a RSS for the java process of 2 GB, isn't that a memory leak?
    No it isn't actually: it is the use of a lot of memory. Not the same thing. If you saw a constant upward trend of memory usage and eventually OutOfMemoryErrors, that's a memory leak. And none of that has anything necessarily to do with threads.
    Will jvm release those handles when there will not be any physical memory available?
    Java will release unreachble objects during garbage collection. That will have the side-effect of releasing system resource handles.
  • 5. Re: question on thread
    AlleT Explorer
    Currently Being Moderated
    Java will release unreachble objects during garbage collection. That will have the side-effect of releasing system resource handles

    This does not happen: the footprint of the java process grows and grows until it reaches out of memory and crashes. Nevertheless jconsole shows the effects on garbage collections on heap space.

    We have also tried to set parameter -XX:MaxDirectMemorySize to limit the NIO buffers but it didn't work too.



    Regards

    Edited by: AlleT on 27-ott-2011 6.23

    Edited by: AlleT on 27-ott-2011 6.24
  • 6. Re: question on thread
    jschellSomeoneStoleMyAlias Expert
    Currently Being Moderated
    AlleT wrote:
    Java will release unreachble objects during garbage collection. That will have the side-effect of releasing system resource handles

    This does not happen:
    It does happen. On hundreds of thousands of applications.

    It might help if you describe you actual problem - the thing that you have which doesn't work.
    Versus just providing some data and then providing your analysis to suggest why it is wrong.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points