1

Is there any way in JVM (tomcat) where we can empty the heap space once in a day by writing any program or by using any settings.

Garbage Collector is a way, I want to know any alternate to GC.

TheLostMind
  • 35,966
  • 12
  • 68
  • 104
Shahbaz Khan
  • 145
  • 3
  • 11
  • 7
    Turn it off and back on again – JonK Aug 07 '14 at 08:27
  • You can free all heap space by killing the program. There is *no* other way and there never will be. Maybe you don't want to free all heap space? – user253751 Aug 07 '14 at 08:43
  • Also, garbage collection is a fully automatic process that you should rarely need to think about. – user253751 Aug 07 '14 at 08:44
  • It is not possible to turn off the server. Any Alternate to this – Shahbaz Khan Aug 07 '14 at 08:46
  • 1
    @ShahbazKhan Like I just said, it's impossible except by killing the program (which could include shutting down the entire machine) - and that's only because the heap *stops existing* if the program isn't running (other programs that are still running have their own heaps, but that one is gone). Why do you think you want to do it? – user253751 Aug 07 '14 at 08:47
  • Some objects are occupying the heap space and not releasing, so the tomcat is going down frequently due to OutOfMemoryError, I am working on its solution but till that i need some program which takes care of server and Release objects implicitly. – Shahbaz Khan Aug 07 '14 at 09:44
  • So you're experiencing a memory leak and you'd better [find it](http://stackoverflow.com/q/40119/581205). Releasing the whole heap is indeed equivalent to program restart and that's not the way to go. – maaartinus Aug 07 '14 at 13:23

0 Answers0