diff --git a/http/vibe/http/server.d b/http/vibe/http/server.d index 023eb6e432..64c1faa2b3 100644 --- a/http/vibe/http/server.d +++ b/http/vibe/http/server.d @@ -1774,9 +1774,9 @@ private void handleHTTPConnection(TCPConnection connection, HTTPListenInfo liste import vibe.internal.utilallocator: RegionListAllocator; version (VibeManualMemoryManagement) - scope request_allocator = new RegionListAllocator!(shared(Mallocator))(1024, Mallocator.instance); + scope request_allocator = new RegionListAllocator!(shared(Mallocator), false)(1024, Mallocator.instance); else - scope request_allocator = new RegionListAllocator!(shared(GCAllocator))(1024, GCAllocator.instance); + scope request_allocator = new RegionListAllocator!(shared(GCAllocator), true)(1024, GCAllocator.instance); handleRequest(http_stream, connection, listen_info, settings, keep_alive, request_allocator); } (); diff --git a/utils/vibe/internal/utilallocator.d b/utils/vibe/internal/utilallocator.d index 9632d3e253..22dfae5ac8 100644 --- a/utils/vibe/internal/utilallocator.d +++ b/utils/vibe/internal/utilallocator.d @@ -5,7 +5,7 @@ public import std.experimental.allocator.mallocator; public import std.experimental.allocator.building_blocks.affix_allocator; -final class RegionListAllocator(Allocator) : IAllocator { +final class RegionListAllocator(Allocator, bool leak = false) : IAllocator { import vibe.internal.memory_legacy : AllocSize, alignedSize; import std.algorithm.comparison : min, max; import std.conv : emplace; @@ -154,8 +154,10 @@ final class RegionListAllocator(Allocator) : IAllocator { Pool* pnext; for (auto p = cast(Pool*)m_freePools; p; p = pnext) { pnext = p.next; - m_baseAllocator.deallocate(p.data); - m_baseAllocator.deallocate((cast(void*)p)[0 .. AllocSize!Pool]); + static if (!leak) { + m_baseAllocator.deallocate(p.data); + m_baseAllocator.deallocate((cast(void*)p)[0 .. AllocSize!Pool]); + } } m_freePools = null;