Fix InvalidMemoryOperationError in DebugAllocator

This fixes errors which fail unit tests when using DebugAllocator.
Same here