www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - GC.collect vs. GC.minimize

reply Brother Bill <brotherbill mail.com> writes:
Is it the case that GC.collect forces a typical GC cycle, and 
GC.minimize does a full mark and sweep?
Sep 23
parent reply =?UTF-8?Q?Ali_=C3=87ehreli?= <acehreli yahoo.com> writes:
On 9/23/25 7:33 AM, Brother Bill wrote:
 Is it the case that GC.collect forces a typical GC cycle, and
 GC.minimize does a full mark and sweep?
GC.collect is already "full collection" as quoted from here: https://dlang.org/library/core/memory/gc.collect.html GC.minimize is a request to GC to give the underlying unused memory back to the OS. To me, it's useful in rare cases where an application does lots of allocations early on and then gets into a steady state of low memory usage. The program can request the GC before getting to that steady state to give the memory back to the OS, which the GC might still be holding on in hopes of reusing it in the future. So, a GC.minimize translation: "I know I will not need memory close to what I've used so far; give all your free blocks back to the OS." Ali
Sep 24
parent Brother Bill <brotherbill mail.com> writes:
On Wednesday, 24 September 2025 at 22:55:57 UTC, Ali Çehreli 
wrote:
 So, a GC.minimize translation: "I know I will not need memory 
 close to what I've used so far; give all your free blocks back 
 to the OS."

 Ali
Does D do 'Generational' GC, or is it simply if there isn't enough memory, to do a 'collect'?
Sep 28