Hi Robert,

I have started to add some hook in osg::Referenced to be able to catch
information about instanciation and destruction, My idea was to add an
InstanceHandler like the DeleteHandler.
i have tried to use thos two mecanism to be able to catch creation and
destruction without more intrusive code in Referenced.cpp

The problem is that Referenced can be created without new. So it means
that the DeleteHandler will not be called with my specific code. Before
(when 'hacked') it works because I have a symmetric mechanism
(constructor/destructor).

I dont see another solution than patching the destructor of Referenced
to call the an Unlog method or a more generic name. To be clear can we
have a second mecanism to log/unlog instance of referenced. I can add a
compile time flag and/or environnement variable. But without doing that
I dont know how to do it.

Any Idea ?

Cheers,
Cedric


On Sun, 2010-08-08 at 15:06 +0100, Robert Osfield wrote:
> Hi Cedric,
> 
> I'm just quickly scanning through osg-users as I'm only around briefly
> before I head off on another weeks trip, this means I don't have time
> to dive in and start reviewing code and thinking about various
> possibilities.
> 
> The best I can do right now is to give you my first gut reaction.
> First up I have now strong opinion on this general feature, the only
> key part would be that it doesn't affect performance or overcomplicate
> code and risk introducing bugs.  Second thought is that having
> multiple interfaces that can be customized would complicate the API
> and implementation, so might it be possible wrap it all up in one
> customizable functor i.e something like generalizing the DeleteHandler
> so it can do what it does right now and do the extra stuff you want.
> It might need renaming as a class, but I doubt it would affect too
> many users as DeleteHandler is a very niche feature.
> 
> Robert.
> 
> On Mon, Aug 2, 2010 at 8:39 AM, Cedric Pinson
> <cedric.pin...@plopbyte.net> wrote:
> > Hi Robert,
> >
> > I have work on a small tool to detect how a program evolve during time,
> > It tracks the numer of instance of each object inherited from
> > osg::Referenced. I use this to detect 'leak' but release when quitting
> > the program so not really a leak  but to detect consumption of too much
> > memory during runtime.
> > The tool to works need modification in osg::Referenced. because there is
> > already a mecanism to set a custom DeleteHandler, I thought we could do
> > the same to intercept instanciation of osg::Referenced with a custom
> > InstanceHandler ?
> >
> > In my use case, I have used a NodeCallBack that dump every second the
> > current instance of Referenced and Object, then I have used a function
> > to dump the gnuplot script from the data store each seconds.
> > Some screenshoot will help to understand how I use it:
> >
> > http://plopbyte.net/tmp/combined.png
> > http://plopbyte.net/tmp/individual.png
> >
> > here the data generated to build the graph
> > http://plopbyte.net/tmp/data.dat
> > http://plopbyte.net/tmp/plot.script
> >
> >
> > What do you think ?
> >
> > I have attached my modified Referenced and Referenced.cpp to work with
> > my tool, but It would need to be more generic like the DeleteHandler to
> > enter in OSG.
> >
> >
> >
> > Cheers,
> > Cedric
> >
> > --
> > Provide OpenGL, WebGL and OpenSceneGraph services
> > +33 659 598 614 Cedric Pinson mailto:cedric.pin...@plopbyte.net
> > http://www.plopbyte.net
> >
> > _______________________________________________
> > osg-users mailing list
> > osg-users@lists.openscenegraph.org
> > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> >
> >
> 

-- 
Provide OpenGL, WebGL and OpenSceneGraph services
+33 659 598 614 Cedric Pinson mailto:cedric.pin...@plopbyte.net
http://www.plopbyte.net

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to