• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

java.lang.OutOfMemoryError on server

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
Yesterday I posted a message with topic "Will it ever be GCed?". Dave Boden gave a perfect answer. Thanks, Dave. I have another question. This is the real reason I posted a message yesterday.
I got the "OutOfMemoryError" on the server while many clients called. Is there any way to programatically check how memory are left?
My server code will create a thread for each clients call. The run() for each thread will do some time-consuming job. The server ends up createing a lot of threads when many clients call. Eventurally JVM for server runs out of memory and the server dies. I understand that "OutOfMemoryError" is unchecked exception. I will not be able to catch it. But how can I prevent the server from dieing like that? I would like the server to tell client this memory problem rather than die itself.
Any help would be greatly appreciated.
TIA
Zheng
 
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Make sure that your threads are being joined when their service is done, or returned to a pool, if you do it that way.
How many clients are you creating? I can't imagine that Sun's test harness will create so many threads as to run their JVM out of memory. Their are switches to allow a larger heap size in the JVM, if needed, but they want to see if your program works, not to test the hardware or the JVM.
 
Zheng Huang
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What if it is for the real application? Does anybody give any thought on this?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic