So, I have a DLL written in C ++. However, it allocates memory using the GlobalAlloc () function. To avoid memory leaks, I want to track these allocations and de-distribute them all when the DLL is destroyed.
Is there a way to write a function that will be called when my DLL is unloaded? One thing I can think of is to create a global object in my DLL and record the memory-free calls in its destructor, but that seems redundant. My other idea is to simply rely on the operating system to free up memory when the DLL is unloaded, but it seems dirty.
thank
source
share