Skip to content

Commit

Permalink
Implement operator delete on ThreadStressLog (#64478)
Browse files Browse the repository at this point in the history
  • Loading branch information
cshung authored Feb 1, 2022
1 parent ddbd0a2 commit ea76f4e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/coreclr/inc/stresslog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
Expand Down
13 changes: 13 additions & 0 deletions src/coreclr/utilcode/stresslog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ea76f4e

Please sign in to comment.