diff --git a/src/coreclr/inc/stresslog.h b/src/coreclr/inc/stresslog.h index 4ee3acaeb8bb6c..35381a17cbb310 100644 --- a/src/coreclr/inc/stresslog.h +++ b/src/coreclr/inc/stresslog.h @@ -740,6 +740,7 @@ class ThreadStressLog { #if defined(MEMORY_MAPPED_STRESSLOG) && !defined(STRESS_LOG_ANALYZER) void* __cdecl operator new(size_t n, const NoThrow&) NOEXCEPT; + void __cdecl operator delete (void * chunk); #endif ~ThreadStressLog () diff --git a/src/coreclr/utilcode/stresslog.cpp b/src/coreclr/utilcode/stresslog.cpp index 5d13b2ec7695ca..0d6f4cd53c93f0 100644 --- a/src/coreclr/utilcode/stresslog.cpp +++ b/src/coreclr/utilcode/stresslog.cpp @@ -965,6 +965,19 @@ void* __cdecl ThreadStressLog::operator new(size_t n, const NoThrow&) NOEXCEPT return malloc(n); #endif //HOST_WINDOWS } + +void __cdecl ThreadStressLog::operator delete(void* p) +{ + if (StressLogChunk::s_memoryMapped) + return; // Giving up, we will just leak it instead of building a sophisticated allocator +#ifdef HOST_WINDOWS + _ASSERTE(StressLogChunk::s_LogChunkHeap); + HeapFree(StressLogChunk::s_LogChunkHeap, 0, p); +#else + free(p); +#endif //HOST_WINDOWS +} + #endif //MEMORY_MAPPED_STRESSLOG #endif // STRESS_LOG