Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

How to avoid OutOfMemory?

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?

Thanks in advnace.
 
Sheriff
Posts: 21804
104
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

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.
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Gagan Popli
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Guys...
 
The moustache of a titan! The ad of a flea:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!