bidnavi (lee)
Java program, unlike C program will swap to virtual memory if out of
physical memory. Java only allocate a block of physical memory for
JVM to run application.

I have a servlet that will receive pretty heavy http request. There
will be a chance of OutOfMemory Error if it receives too many request
at a time.

Any good way I can prevent OutOfMemoryError to happen? Since If the
JVM throws an OutOfMemroyError, that means JVM is crashed and it will
no longer function correctly until I restart the JVM (servlet engine)
I think.

What I am thinking to do is to set a upperbound memory usage in my
servlet, If servlet find out JVM is almost out of the memory, It will
block(stop process) anymore client request and just return an error
code like --> server busy something like that. That will prevent
servlet crash the VM.

I wonder if there is any better way? except calling gc().


2001-7-10 -04:00

回到话题: java.lang.outOfMemoryError

回到论坛: HOME枫下论坛枫下论坛主坛工作学习IT技术讨论