Figuring Out Why My Program Eats So Much Memory

Discussion in 'Java' started by Dale, Sep 19, 2003.

  1. Dale

    Dale Guest

    I need some kind of heap analyzer tool or something that will tell me
    what Objects are not getting collected by the GC. The program starts
    a bunch of objects, and each object runs in it's own thread. The test
    objects usually makes a connection of some type, and does a test. At
    the end of the test, or at a timeout, each one of those objects calls
    back with the result of the test. These tests are scheduled every 20
    minutes. In each of these test objects, the run method stops after it
    reports back, and that should be it. But in Windows NT processes, I
    see this program takes up more and more memory as the days go by (it's
    up to 74,732K at the moment). If I stop and restart, it settles at
    about 18,000K, but slowly makes it's way up to that 75,000K range
    after a couple of days.

    Is there a way to list the objects the JVM thinks are still active?

    --Dale--
     
    Dale, Sep 19, 2003
    #1
    1. Advertising

  2. In article <>,
    (Dale) wrote:

    >:I need some kind of heap analyzer tool or something that will tell me
    >:what Objects are not getting collected by the GC. The program starts
    >:a bunch of objects, and each object runs in it's own thread. The test
    >:eek:bjects usually makes a connection of some type, and does a test. At
    >:the end of the test, or at a timeout, each one of those objects calls
    >:back with the result of the test. These tests are scheduled every 20
    >:minutes. In each of these test objects, the run method stops after it
    >:reports back, and that should be it. But in Windows NT processes, I
    >:see this program takes up more and more memory as the days go by (it's
    >:up to 74,732K at the moment). If I stop and restart, it settles at
    >:about 18,000K, but slowly makes it's way up to that 75,000K range
    >:after a couple of days.
    >:
    >:Is there a way to list the objects the JVM thinks are still active?
    >:
    >:--Dale--


    There are some commercial profiling tools available. We've been using
    OptimizeIt, now available from Borland. They may still offer a demo to
    get a feel for what it can do.

    Another key thing is to get familiar with Java's memory management
    scheme in general. It pays to learn how the heap works, about garbage
    collection, etc. You do realize that those Thread objects don't go away
    when they stop, right? Any Thread (or subclass) is not considered alive
    when its run() method terminates, but the object is there until you
    remove it -- provided it's referred to anywhere. And, despite what some
    people think, it can prevent itself from getting cleaned up if some of
    its own member variables reference certain objects outside itself. It's
    a complicated topic, when you're forced to get into it.

    = Steve =
    --
    Steve W. Jackson
    Montgomery, Alabama
     
    Steve W. Jackson, Sep 19, 2003
    #2
    1. Advertising

  3. Dale () wrote:
    : Is there a way to list the objects the JVM thinks are still active?

    Get a profiler and check the heap.

    In the standard jdk you have the hprof profiler that is not very user
    friendly, but always available.

    There are a few free profilers like jmp (which I develop and use) find
    it at http://www.khelekore.org/jmp/
    You can also try mjp at http://mjp.sf.net/ or if you happen to use
    eclipse there is the eclipse profiler plugin (havent tried it myself
    but seems to provide standard profiling options). Find it at:
    http://eclipsecolorer.sourceforge.net/index_profiler.html

    If you instead prefer to spen a lot of money you can try jprobe,
    optimizeIt or jprofiler (a quick google will show you the
    sites). Personally I dont like any of the commercial versions, but
    you should be able to find a 30 day trial version if you look
    around...

    have fun
    /robo
     
    Robert Olofsson, Sep 19, 2003
    #3
  4. Dale

    Roedy Green Guest

    On 19 Sep 2003 08:16:47 -0700, (Dale)
    wrote or quoted :

    >I need some kind of heap analyzer tool or something that will tell me
    >what Objects are not getting collected by the GC


    see http://mindprod.com/jgloss/profiler.html

    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
     
    Roedy Green, Sep 19, 2003
    #4
  5. Dale

    Dale Guest

    Steve, Robert & Roedy,

    Thanks for the suggestions - things worked out really well. After
    checking out the references and web contentes, I settled on
    http://www.khelekore.org/jmp/ and picked-up the code there. It was
    immediately apparent that a certain test (Object) was not being
    garbage collected (there was a zero in the GC column... not what I
    expected). So I did a bit of reading (these are objects that are part
    of an enterprise integration architecture tool) and found some destroy
    methods. Once I put those in there, I was golden (10K and holding for
    a few days now). Thanks.

    --Dale--

    (Dale) wrote in message news:<>...
    >
    > Is there a way to list the objects the JVM thinks are still active?
     
    Dale, Sep 25, 2003
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kevin Spencer

    Re: ASP.NET eats memory too much

    Kevin Spencer, Jun 30, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    443
    Kevin Spencer
    Jun 30, 2003
  2. George Ter-Saakov

    Re: ASP.NET eats memory too much

    George Ter-Saakov, Jun 30, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    390
    George Ter-Saakov
    Jun 30, 2003
  3. Jos Vernon

    Re: ASP.NET eats memory too much

    Jos Vernon, Jul 1, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    388
    Jos Vernon
    Jul 1, 2003
  4. Mr. SweatyFinger
    Replies:
    2
    Views:
    2,127
    Smokey Grindel
    Dec 2, 2006
  5. Plateriot
    Replies:
    2
    Views:
    345
    Plateriot
    May 23, 2008
Loading...

Share This Page