P/Invoke FreeLibrary()

D

dh

After using Win32 FreeLibrary() to unload a DLL in a C# app, will the DLL be
immediately removed from memory, or it go through the same mechanism of GC
of .NET like other objects in C# code?
 
J

Jeroen Mostert

dh said:
After using Win32 FreeLibrary() to unload a DLL in a C# app, will the DLL be
immediately removed from memory, or it go through the same mechanism of GC
of .NET like other objects in C# code?
Neither. FreeLibrary() will decrease the reference count. If it reaches
zero, the library will be unloaded. This is just the same as for unmanaged code.

A DLL is not a managed object, so garbage collection has nothing to do with it.
 

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