• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

out of memory error

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am getting a out of memory error, when I tried to increase the jvm size, then the problem is not coming for one program and for other it is still facing the same problem(both programs are having same logic almost for different purpose)
As I couldn't increase my jvm size according to my wish I tried to close all the objects that I am using in the program.what additional things I need to consider to overcome this problem?
 
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would advice you to do performance profiling of your applicaition using tools like OptimiseIt. You need to look for memory leaks in your code.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I tried to close all the objects that I am using in the program


What does this mean? Assuming you mean you have dereferened them, this does not free them from memory. If you need stuff to be shifted out of memory more fequently, have a look a configuring you JVm's garbage collector.

Why can't you increase the amount of memory available? Have you tried performance testing your app. to find out how much it needs?
 
Bartender
Posts: 1638
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are on jdk 6, you can use this jvm option:

-XX:+HeapDumpOnOutOfMemoryError

This option will generate a head dump whenever there is an out of memory error. You can analyze the dump using jhat

More good links and tips on this blog entry. (The blog entry is specifically on jdk6)
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Take a look at following two issues:
1. database connections - always close result sets, connections if you use database data.
2. collections - always clear collections (lists, vectors, etc) when you don't need them anymore.

From my experience, that solves more than 80% of memory leak problems.
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Outof memory only when it come when there is no memory for JVM....
Allocate the memory for your application..... And best thing is do the code profiling which will give you the better picture .... on your application memory leak... Due to that your JVM get squeez.....

Jaffer ....
 
reply
    Bookmark Topic Watch Topic
  • New Topic