Help! Flush Jvm, Java.lang.outof Memory


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Help! Flush Jvm, Java.lang.outof Memory

  1. #1
    Join Date
    May 2004
    Posts
    1

    Help! Flush Jvm, Java.lang.outof Memory

    I'm using a java applet that paints a table-based database grid and running it on apache server. It works fine but after 2-3 hours of reloading (which initializes and draws the applet again to show the DB's most recent data), the browser will not render the applet.

    When I put my mouse over the applet, I see a java.lang.outofmemory error.

    The work-around is to open and close the browser(which kills the JVM instance).

    How can I prevent this? Or better yet, how I can I flush the JVM's memory so that every time I repaint the applet, the JVM's stack will not overflood.

    BTW, memory increase will only increase the time it takes for the applet to crash but I'd rather flush it when I refresh the browser somehow.

    Any help would be greatly appreciated.

    thanks,

    Robert

  2. #2
    Join Date
    May 2004
    Posts
    11
    Simple approadh is to call :
    System.gc();

    This will just request that garbage collection be ran....it may not actually run, and it is only a temporary solution. You NEED to find out what objects you are not cleaning up/releasing and fix it, otherwise you will continue to run out of memory. Are you closing you sql statements (and other jdbc objects) when you are finished? They are memory intensive and WILL not be garbage collected until they are closed by you or a parent object.

  3. #3
    Join Date
    May 2004
    Posts
    5
    Reloading the page document.location.reload() will free the applet.

    You can find which objects are not garbage collected using a profiler. The easiest way is to create a small program that puts the applet in a Frame and run it in the profiler.

    To determine the objects that are not freed:
    1. Reset the heap instance counters to 0.
    2. Perform the operations implemented by the applet.
    3. Run the garbage collector.
    4. Some instance counters may have changed. Analyze if these new instances are needed and if not determine the references preventing the garbage collection and find a solution to brake them.

    I'm currently using OptimizeIt.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center