[Issue 18854] std.allocator: StatsCollector counts failed deallocations

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue May 15 23:43:57 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=18854

Vladimir Panteleev <dlang-bugzilla at thecybershadow.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrei at erdani.com

--- Comment #1 from Vladimir Panteleev <dlang-bugzilla at thecybershadow.net> ---
StatsCollector.deallocate is "Defined whether or not `Allocator.deallocate` is
defined". I'm really not sure this was a great idea, because it opens the door
to silent memory leaks, and breaks introspection of any allocators that might
use this information to switch to a different method of tracking allocations.

There's two ways to fix this:

- Make deallocate always return false (and not count allocations) when
ParentAllocator doesn't support deallocation.
- Don't define deallocate if the parent allocator doesn't.

I feel like the first one would defeat the point of always having a deallocate
method. Still, the way things are now is obviously broken.

Andrei, any thoughts?

--


More information about the Digitalmars-d-bugs mailing list