-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Fix memory leak in SuperPMI #34523
Fix memory leak in SuperPMI #34523
Conversation
@sandreenko PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
@@ -41,6 +41,16 @@ CompileResult::~CompileResult() | |||
|
|||
if (CallTargetTypes != nullptr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: You can delete the null checks for these - to make the style consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you.
superpmi test is failing |
Introduced by change to Heap APIs. Also fixes a long-existing memory leak on Linux. Introduce a small, simple class to keep track of memory allocations associated with the CompileResult that we need to free. In the replay case, SuperPMI allocates these (such as for the JIT calling allocMem). In the case of collection, the VM allocates memory for allocMem (and related), so that memory doesn't need to be tracked.
51288f7
to
e0f5444
Compare
In the replay case, the previous code was correct. However, in the collection case the memory from |
void* allocate(size_t sizeInBytes) | ||
{ | ||
BYTE* pNew = new BYTE[sizeInBytes]; | ||
m_pHead = new MemoryNode(pNew, m_pHead); // Prepend this new one to the tracked memory list. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: This has memory leak if new MemoryNode
throws, but I assume that we do not care about hardening like this in superpmi.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I'm not too worried about hardening superpmi for OOM
Introduced on Windows by change to Heap APIs (#34289).
Also fixes a long-existing memory leak on Linux where we never had
HeapDestroy()
.