How to use destroy and free.

cc cc at nevernet.com
Wed May 4 15:04:13 UTC 2022


The MemUtils package offers a `ScopedPool` utility that seems 
interesting.  It isn't well documented however so I have no idea 
if it actually works like I expect.  I presume this would work 
something akin to a VM memory snapshot/rollback for the GC?  It 
would be pretty handy for some scenarios, say a serialization 
library.  You specify a snapshot point (add a pool to the 
stack?), incur all your GC allocations necessary for generating 
the structure of your serialized data (which go into the pool 
instead of the GC proper?), then you write it to disk and pop the 
stack, effectively rolling back to the original memory state of 
your program's GC.  As long as you make sure not to leak anything 
allocated within that phase, seems like a good deal.

https://code.dlang.org/packages/memutils


More information about the Digitalmars-d-learn mailing list