[osg-users] osgDotNet : Nodes adding to scene graph outside main() function scope

Christophe Medard christophe.medard at oktal.fr
Fri Sep 21 08:47:57 PDT 2007


Hi all, 

If I can still think straight (after such a long week), there seems to be a major problem for people that want to code special Effects in osgDotNet in C#  : 
If you want to add to your main scenegraph osg::Nodes that are held by (because created, updated and modified by) an SFX class, you quickly have memory corruption problems due to the fact that Dispose calls are done on those nodes whose reference count is greater than 0.  

This problem doesn't occur in a similar code written in C++ - using native osg dlls - in which a destructor is implementable for the SFX class, and osg::Referenced::ref() (resp. unref()) methods can be called when osg::Nodes are created (resp. inside SFX class' destructor).

I'm attaching a very short C# example illustrating that.
The application crashes rapidly, in Release or Debug. The shallow Debug trace is :









I must say to be complete that for instance I'm using version 2.0.0 of OSG and osgWrappers.

If there's is a way to avoid those Dispose calls on regular Nodes I'm interested to know !!
(My preceeding attemps of sfx implementation in C# where done roughly entirely in the main() function, which doesn't raise problems...)

-- 
Christophe Médard
Société OKTAL (http://www.oktal.fr)
2 impasse Boudeville
31100 Toulouse (France)
Tél. : (+33) 5 62 11 50 10
Fax : (+33) 5 62 11 50 29

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20070921/f042327a/attachment-0002.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 97787 bytes
Desc: not available
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20070921/f042327a/attachment-0004.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 10844 bytes
Desc: not available
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20070921/f042327a/attachment-0005.png>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: SamplePbWithRefCount.csproj
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20070921/f042327a/attachment-0002.asc>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ArgumentParser.cs
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20070921/f042327a/attachment-0006.txt>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: MySfx.cs
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20070921/f042327a/attachment-0003.asc>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Program.cs
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20070921/f042327a/attachment-0007.txt>


More information about the osg-users mailing list