D compiler benchmarks

Daniel Keep daniel.keep.lists at gmail.com
Sat Mar 7 16:36:01 PST 2009



Robert Clipsham wrote:
> ...
> 
> (if anyone knows an easy way to get the memory usage of a
> process in D, let me know :D).

There's a way to do it in Phobos;

> import gc=std.gc;
> import gcstats;
>
> void main()
> {
>     GCStats gcst;
>     gc.getStats(gcst);
> }


I went hunting through Tango, and it looks like it has the same method;
it just isn't exposed.  Probably because of this comment:

// NOTE: This routine is experimental.  The stats or function name may
//       change before it is made officially available.

None the less, if you want it now, you could try adding this to your
code somewhere:

> struct GCStats
> {
>     size_t poolsize;        // total size of pool
>     size_t usedsize;        // bytes allocated
>     size_t freeblocks;      // number of blocks marked FREE
>     size_t freelistsize;    // total of memory on free lists
>     size_t pageblocks;      // number of blocks marked PAGE
> }
>
> extern(C) GCStats gc_stats();

You should probably whack this in a module so you can replace it easily
if and when it changes.


  -- Daniel



More information about the Digitalmars-d mailing list