If I use C# to P/Invoke a certain DLL, will the actual C++ DLL be run for the duration of the call and then be shut down, destroying all used memory? Or will .NET take charge of the memory used by the C++ DLL in an unmanaged "heap" and give pointers to those objects to the C++ DLL everytime I call a static function?
When I need a certain C++ project to have its memory persistant, should I be creating an ActiveX/COM Server to have its memory persist, and yet be able to call it from C#?
If I use C# to P/Invoke a certain DLL, will the actual C++ DLL be run for the duration of the call and then be shut down, destroying all used memory?
No. Once the DLL is loaded it will stay loaded. The DLL's lifetime is not tied to a function call. This means that variables in the DLL that have static storage persist beyond the initial p/invoke call.
If you are creating an object from a C++-DLL, it will actually persist until you delete it or rather dispose it. As you need to manually remove unmanaged objects, it will stay.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With