Memory detection

Charles Hixson charleshixsn at earthlink.net
Thu Aug 23 16:13:39 PDT 2012


Is it possible to detect when a program is using, say, 90% of the memory 
that is available, so that I can take steps to reduce usage?  I've got a 
method that would like to use probably more memory than is available, 
but which can (if it could tell) save stuff to files to free memory it 
isn't using at the moment.  But when I looked in 
http://dlang.org/phobos/core_memory.html all the methods seemed to have 
to do with garbage collection, which isn't quite the same thing.  I 
don't want the stuff to be garbage collected until after I've saved it's 
current state, but to know when to do that, I need to know how much 
memory is currently free.

I suppose that I could set an arbitrary limit on the number of various 
things I allow before compacting, but that's a bit ... arbitrary.  And 
doesn't adapt to different machines without recompiling.


More information about the Digitalmars-d-learn mailing list