digitalmars.D.learn - Minimise and collect by GC when OutOfMemory
- tcak (5/5) Feb 25 2016 Would it be a good idea to call "collect" and "minimize" methods
- Chris Wright (10/16) Feb 26 2016 If OutOfMemoryError is thrown, the GC has already done everything it can...
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.
Feb 25 2016
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.
Feb 26 2016