C# wrapper garbage collector problem

I am using c# wrappers generated by swig and am experiencing strange problems associated with garbage collector/memory management. The code randomly disposes variables (even global variables). I tried using GC.keepAlive() function, from C# but have not found it much helpful. Any kind of hint/help would be appreciated since I have no clue what's happening.

Naehfix's picture

The GC is that real reason why it is not very useful to use automatic generated Wrappers. OCC has some strange Management of their Built-In-Classes. They have their classes i.e. V3d_Viewer and the Handles Handle_V3d_Viewer. First I tried to use the pure classes in my wrapper an experienced a lot of Problems. Then I switched to the Handles and everthing worked fine. BUT I had to write two DLLs to get OCC usable in a C# Project.

www.jay-code.de/lo/OpenCascadeWrapper.zip

This is my sample-Code so far. You may feel free to take a look at it.