How memory is managed for C# objects when C++ code uses as C# class?
How memory is managed for C# objects when C++ code uses as C# class?
NOTE: I am not specific in this question 开发者_如何转开发but just wondering how it is done.
It works exactly the same... objects that are not reachable by managed code are eligible for garbage collection so if your unmanaged code is relying on managed resources to continue existing you must hold a reference to it somewhere in the c# side of the app.
edit: this applies to unmanaged c++
Managed C++ uses the ordinary garbage collector.
精彩评论