More std.allocator goodies coming your way: better statistics

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Mon May 18 13:30:27 PDT 2015


On 05/18/2015 08:53 PM, Andrei Alexandrescu wrote:
> Beautiful statistics accumulated for the allocator instance and/or per
> call location:
>
> http://erdani.com/d/phobos-prerelease/std_experimental_allocator_stats_collector.html
>
>
> https://github.com/andralex/phobos/blob/allocator/std/experimental/allocator/stats_collector.d
>
>
> Destructors welcome.
>
>
> Andrei

- The documentation for numAllocateOK is wrong. (Allocating zero bytes 
is always successful.)

- bytesHighTide is not properly updated. (I suggest to just move the 
check into the implementation of 'add' and be done with it.) Also, is 
this really the only value where it is useful to track a maximum, or 
other summaries?

- The documentation is inconsistent on whether bytesContracted should be 
changed in deallocate; the implementation does it. (I don't see why it 
should.)

- 'static struct Voldermort'

- I think line 602 is not what you wanted.
   'if (!s.next && root != &s)'
   !s.next <-> 's' has not been added, or it is the last element of the 
list
   root != &s <-> 's' is not the first element of the list

   I.e. if 's' is the last element of a list that contains more than one 
element, the list will become cyclic.


More information about the Digitalmars-d mailing list