In certain portions of code (speed critical bits for example), you wouldn't want the GC
making a collection. So to overcome this you can disable the garbage collector by using
this peice of code:
Once you have disabled it, you must manually re-enable it by having this:Code:std.gc.disable();
You can also make it run collections, unlike the Java and .NET GCs, this is not a requestCode:std.gc.enable();
command, it will force the collection to run:
Code:std.gc.fullCollect();That will make a full collection, it will take longer then the second type, but will
pick up all the "garbage".
This will do a generation collection, which will be faster then a full mark and sweepCode:std.gc.genCollect();
collection, but may not pick up all the "garbage".
It is important when trying any of these peices of code, that you put this at the top of
the file:
So you have access to the std.gc module.Code:import std.gc;
Interested in participating in community events?
Want to harness your programming skill and turn it into absolute prowess?
Come join our programming events!
Nice bit of info! +rep
Interesting fact. Thanks.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks