Advice Troubleshooting Memory Leaks Using PInvoke  
Author Message
redfish





PostPosted: Visual C# General, Advice Troubleshooting Memory Leaks Using PInvoke Top

I have made an application in C# that uses a lot of PInvokes to the Win32 that create shared memory using VirtualAllocEx and more. I have a pretty bad memory leak now. Surprise! I have no experience dealing with this problem. What is the best way to find memory leaks in NET Or do i simply try random things and cross my fingers

Visual C#12  
 
 
Andreas Johansson





PostPosted: Visual C# General, Advice Troubleshooting Memory Leaks Using PInvoke Top

The way I use is to examine the code and see where memory is allocated and where it is deallocated. I then proceed to check what happens between these two points and that will usually reveal probable memory leaks.



 
 
Bobbias





PostPosted: Visual C# General, Advice Troubleshooting Memory Leaks Using PInvoke Top

Basically, manually trace through everything you do to that pieve of memory, and make sure that nothing in your code will cause it to leak, or somehow be overlooked by your deallocation code.