• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.lang.OutOfMemoryError

 
Dean Fredericks
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This question is so tough, even the most senior engineers here at my company still dont know what is going on. To answer this question you need indepth knowledge of how java allocates its memory.

We are running a large business server written in java, it receives requests via corba interface, does some things, and passese on the request to be porcessed at some other location.

The program has run fine for 6 months or so. Then one day , java.lang.OutOfMemoryError.

This is strange because its running on a HP server with over 4 gigs of memory, and the since of the app in the nt-process list says its was about 90 megs when it crash - so there was plenty memory!

Now, we have looked, I have look many people have looked, there is no memory leak in this app.

WHat is happening? Ive got a feeling its to do with the heap size, but shouldnt java just make a bigger heap if it sees it was need more memory ??

Would appricaite any input from anyone who knows how java works, how it allocotes memory, the role the heap plays, and has experience with the out of memory error!!

thanks guys!
cheers !
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
3 possibilities:
Windows will only allow a process to take 2Gig max. I believe this gets better post-Server 2003
Java 1.4 and before will only allow 1.5Gb anyway, this may limit you further.
It may be the heap size. We had this too. It's another -XX option but I'll have to go look for it.

As you may have guessed, we have some app using large chunks of memory.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Dean Fredericks:

This is strange because its running on a HP server with over 4 gigs of memory, and the since of the app in the nt-process list says its was about 90 megs when it crash - so there was plenty memory!


Sun's JVMs (and most others) have a maximum Java heap size, set on JVM startup. When that heap is filled and garbage collection can't free any memory, you'll get an OutOfMemoryException. The default maximum Java heap size is 64MB, for a total OS memory usage of something like 90MB. It doesn't matter how much RAM the machine has in total -- the JVM won't allocate any more than its preset maximum heap size.

For Sun's JVMs, the command-line switch to set the maximum heap size looks like "-Xmx1234m", where "1234" is the number of megabytes of RAM to use for the Java heap. If you're not using a standard Sun JVM, then check the documentation for the appropriate switch to use.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
-XX:PermSize is what I was trying to remember, just looking for a good link.
[ April 08, 2005: Message edited by: David O'Meara ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic