File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes OutOfMemory Issues Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "OutOfMemory Issues" Watch "OutOfMemory Issues" New topic
Author

OutOfMemory Issues

Doshi Milan
Ranch Hand

Joined: May 29, 2001
Posts: 112
We are having OutOfMemory issues in our appllication.

The logs points to Heap Size issue :

<AF[7380]: Allocation Failure. need 3276816 bytes, 108 ms since last AF>
<AF[7380]: managing allocation failure, action=2 (274822776/1073740288)>
<GC(7420): GC cycle started Thu Sep 14 13:39:32 2006
<GC(7420): freed 14574792 bytes, 26% free (289397568/1073740288), in 4835 ms>
<GC(7420): mark: 1165 ms, sweep: 39 ms, compact: 3631 ms>
<GC(7420): refs: soft 0 (age >= 32), weak 0, final 16, phantom 0>
<GC(7420): moved 2372574 objects, 106665600 bytes, reason=1, used 13592 more bytes>
<AF[7380]: managing allocation failure, action=3 (289397568/1073740288)>
<AF[7380]: managing allocation failure, action=4 (289397568/1073740288)>
<AF[7380]: clearing all remaining soft refs>
<GC(7421): GC cycle started Thu Sep 14 13:39:33 2006
<GC(7421): freed 77864 bytes, 26% free (289475432/1073740288), in 1195 ms>
<GC(7421): mark: 1158 ms, sweep: 37 ms, compact: 0 ms>
<GC(7421): refs: soft 17 (age >= 32), weak 0, final 1, phantom 0>
<GC(7422): GC cycle started Thu Sep 14 13:39:38 2006
<GC(7422): freed 14520 bytes, 26% free (289489952/1073740288), in 4542 ms>
<GC(7422): mark: 1158 ms, sweep: 36 ms, compact: 3348 ms>
<GC(7422): refs: soft 0 (age >= 32), weak 0, final 0, phantom 0>
<GC(7422): moved 286669 objects, 12860328 bytes, reason=1, used 40 more bytes>
<AF[7380]: managing allocation failure, action=6 (289489952/1073740288)>
<AF[7380]: totally out of heap space>
<AF[7380]: completed in 10577 ms>


1. Any idea what should be the next steps for us ?
2. On reseraching the internet, many things points to 'Connection Pooling' , recordset etc but that does not seem to be an issue in our case.


Any inputs to where should we be targetting next ?

All help appreciated.

Thanks,
Milan
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18991
    
    8

Next step should be to find out what kind of objects are really filling up your memory. If your code is doing something like storing elements in a list that expands forever, then that would be your problem. But if you don't see anything obvious like that, you should get a Java profiler and let it watch your memory allocations.
Jignesh Patel
Ranch Hand

Joined: Nov 03, 2001
Posts: 626

Your problem is before GC can collect unused object from memory, your application piling up many more object.

Avoid object creating. It is not at all connection pool problem.
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
Originally posted by Jignesh Patel:
Avoid object creating.


Isn't it rather hard to write a Java program without creating objects ;-)

The problem is unlikely to be how many objects are being created, but rather what is holding references to them.

Almost every Java program creates loads of objects, but most of them are short-lived because references to them are not held for long.

Look for places where you may be storing long-lived references to objects. Global collections, caches, pools etc.


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Doshi Milan
Ranch Hand

Joined: May 29, 2001
Posts: 112
Thanks for all for the valued suggestions.

I agree that it maybe due to the style of coding. Now, our project is over two years old and developed by over 20 different developers. So... the million dollar question is.....

How do we know what code is the Culprit...
How do we know WHICH are the OBJECTS that are NOT being released...
Are there any tools for it ? Can Java Profilier point us to the object which is causing the issue ?If not, which other tool ?

Thanks,
Milan Doshi
Tony Morris
Ranch Hand

Joined: Sep 24, 2003
Posts: 1608
Originally posted by Doshi Milan:
Are there any tools for it ? Can Java Profilier point us to the object which is causing the issue ?If not, which other tool ?

Thanks,
Milan Doshi

Yes, use a profiler.
After you've encountered enough OutOfMemoryErrors, your first call will be a profiler - speculation from another is nothing more than a red herring - and in some cases an impossibility under the given circumstances.


Tony Morris
Java Q&A (FAQ, Trivia)
Doshi Milan
Ranch Hand

Joined: May 29, 2001
Posts: 112
Thanks everyone for valuable inputs, the Profiler has been installed and hopefully provide more information.

Regards,
Milan
Teodora Jevtic
Greenhorn

Joined: Sep 22, 2006
Posts: 1
Running profiler may help you find some leaks, but your application may just need more memory:have you tried changing -Xmx value (to increase memory for JVM). The default value is not that large. Its maximum value can be about 1.4G for a 32bit.
chu martin
Greenhorn

Joined: Sep 27, 2006
Posts: 4
Usually, the major cause for having many live objects cannot be cleared is the wrong scoping and cause the memory leak, so you better check all object variables defined with static outside the method.
Besides, if you increase the xmx heap size, it should be limited by the physical memory; otherwise, it will downgrade the performance a lot due to paging.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: OutOfMemory Issues