Hi,
In an interview, the interviwer asked me, what steps proactively should i take to avoid any OUtOfMemory errors to happen in a java application?
Can anyone help me on this please?
Before you can prevent OutOfMemoryErrors you must understand why and when they are thrown. Only then can you try to remedy them. This remedy may be in code, or by changing / adding flags when you start the JVM. Execute "java -X" (without the quotes) to see some nice flags, and you'll find at least one that could be useful. Hint: the default maximum amount of heap memory a (client) JVM can use is 64MB.
Hi,
OutofMemory is something which can happen at any place, so to avoid them one has profile the application using profiling tools available in the market.
One should find out the places where memory is not released & try to fix them
Application should not hold the objects if they are not required