I have a plan.. I really DO
H. S. Teoh
hsteoh at quickfur.ath.cx
Tue Jul 10 17:03:01 UTC 2018
On Tue, Jul 10, 2018 at 04:07:01PM +0000, SrMordred via Digitalmars-d-announce wrote:
> > As I've already repeated twice, this is not true in D. You *can*
> > predict precisely when the GC runs a collection cycle by calling
> > GC.disable and then calling GC.collect according to *your* own
> > schedule. This is not just a theoretical thing. I have actually
> > done this in my own projects, and it does work.
>
> Sorry, can you help me with this?
>
> Eg.
> void doit()
> {
> int[] x;
> x.length = 1024 * 1024 * 128;
> }
>
> void main()
> {
> import core.memory : GC;
> import core.thread;
> GC.disable;
>
> doit; //alloc +- 500mb inside the func.
> Thread.sleep(5.seconds); //500mb still in use.
> GC.collect; //hmmm still there
> Thread.sleep(5.seconds); //same
> }
[...]
AFAIK, the current GC does not release memory back to the OS. So you
won't see the memory footprint decrease. However, it does free up
memory for subsequent allocations.
T
--
It is of the new things that men tire --- of fashions and proposals and improvements and change. It is the old things that startle and intoxicate. It is the old things that are young. -- G.K. Chesterton
More information about the Digitalmars-d-announce
mailing list