Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement operator delete on ThreadStressLog #64478

Merged
merged 1 commit into from
Feb 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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