On Fri, 26 Feb 2016 05:47:08 +0000, tcak wrote: > Would it be a good idea to call "collect" and "minimize" methods of > core.memory.GC when OutOfMemory error is received FOR A LONG RUNNING > PROGRAM? or there won't be any benefit of that? > > Example program: A web server that allocates and releases memory from > heap continuously.
If OutOfMemoryError is thrown, the GC has already done everything it can to try to get more memory to use. If you find a case in which it helps to call GC.collect and GC.minimize, it's a bug that the GC threw an OutOfMemoryError. ...usually. If you are running on a 64-bit Linux system that has overcommit turned off and more address space than RAM + swap, you can get some mileage from GC.minimize() after OutOfMemoryError. Detecting this situation isn't necessarily easy, which is why the GC doesn't do it already.