Hi all,
  Let's imagine I'm trying to use osgIntrospection to make a
scripting language (hmmm LUA for example) be able to access everything
that is been reflected in osg. That's fine, it's quite easy to use
lua's beautifull mechanisms to know what the user is trying to
instance or what method is trying to invoke. Everything dynamic,
generic, and whatever class of osg is accessible with no cost. (Ok, up
to here is osgLua and works pretty well)

   But... Lua is a garbage-collector based scripting, if someone
instances something the user expects that the GC take care of the
data. That's true, actually osgLua takes the osgIntrospection::Value
and destroys it... but, Value will not destroy the data:

       /// Destructor. Frees internal resources but it does NOT delete
       /// the value held. For example, this function will produce a
       /// memory leak:  void f() { Value v(new int); }
       inline ~Value();

This can cause memory leaks if the user doesn' t take care of it...
(and I'm trying to avoid that) but moreover, for example, if the user
gets from the current scene a node, since osgLua do not increment its
reference, the node can be freed and the script still have a reference
that could be null...

I'm wondering possible solutions to that problem, I came with one that
is quite easy but I want to discuss it:

Make lua to act as a very big ref_ptr handler, if the object inherits
from Referenced then lua uses ref, unref mechanism to handle it. But,
what will happen to those objects that are not referenced? do they
exist in osg? (I'm not sure) How to handle them? Should I make lua
only instances referenced objects?

Cheers,
   Jose L.

--
 Jose L. Hidalgo ValiƱo (PpluX)
 ---- http://www.pplux.com ----
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to