"pause" garbage collection in parallel code

Stephan Schiffels via Digitalmars-d digitalmars-d at puremagic.com
Mon Dec 15 06:01:29 PST 2014


On Monday, 15 December 2014 at 11:54:44 UTC, Daniel Murphy wrote:
> "Stephan Schiffels"  wrote in message 
> news:wjeozpnitvhtxrkhulaz at forum.dlang.org...
>
>> I see several ways how to improve my code:
>> 1.) Is there a way to tell the GC the maximum heap size 
>> allowed before it initiates a collection cycle? Cranking that 
>> up would cause fewer collection cycles and hence spend more 
>> time in my multithreaded code?
>
> Yes, sort of.  You can use 
> http://dlang.org/phobos/core_memory.html#.GC.reserve to have 
> the GC grab a big chunk of memory, and collections won't run 
> until that is exhausted.  As it is only allocating virtual 
> memory, it should be more or less equivalent to setting the max 
> heap size.
>

This doesn't work for me, for some reason. I reserve via 
GC.reserve(4_000_000_000), ensured that it does return at least 
that amount, but the Garbage collector will still collect like 
crazy, long before that reserved memory is exhausted...


More information about the Digitalmars-d mailing list