Memory used in unmanaged space

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
 
A

Andrew Falanga

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top