Memory used in unmanaged space

  • Thread starter Thread starter Andrew Falanga
  • Start date Start date
A

Andrew Falanga

Hi,

I have a program which uses Platform Invoke for two different
unmanaged dlls. It would stand to reason, I think, that the garbage
collector in .NET would not be responsible for cleaning up memory used
by these dlls, but I wanted to ask before assuming that to be true.
When memory is malloc'd or new'd in an unmanaged dll, and it's free'd
or deleted, is it actually released at that time, or when the garbage
collector is done with it? Does the garbage collector have any
influence on the memory allocated by unmanaged code?

Andy
 
Your intuition is correct.  The .NET GC only manages memory allocated from  
managed .NET code.  Memory managed within your unmanaged code is dealt  
with in the usual, unmanaged way.

Pete

Thanks Pete. Just wanted confirmation.

Andy
 
Back
Top