Hi Johannes,

The OSG doesn't try to override the default new and delete, leaving
this up to users if they wish.  As you explain MS create a few wobbles
in this, but this really isn't the OSG fault, its all just standard
C++.

In terms of workarounds, perhaps using a custom DeleteHandler would do
the trick. See include/osg/Referenced.

Robert.

On 6/22/07, Johannes Brunen <[EMAIL PROTECTED]> wrote:
Hi Robert,

after my first steps into the world of osg I have stumbled over a
problem with the memory management. My program uses a custom memory
allocator. I.e. the program has overwritten the global new and delete
operators.
The Windows stl allocator, which is used by default and used by osg,
does map directly onto the global new and delete operators.
Osg objects created via new in my application uses the special new
operator defined by the custom memory handler. However, when the
destruction happens inside the osg dll code, the standard Windows
operator delete is called. This of course breaks consistency. There are
only few ways out of this dilemma:

0. don't use custom memory handlers => no option
1. new and delete for an object may happen only on one side, i.e. in the
application or in the dll => traditional way
2. the dll must be compiled with the very same custom memory allocator
=> typicailly the way I use for my own dlls, but imho license problems
with OLGPL
3. the smart pointers used by osg must carry the deleter function to be
used for deletion of the object. This technique is used imho by the
boost::shared_ptr class. => with this I do have little experience

What is your opinion? Did I oversee something? Are you feeling that this
is a major problem to be solved?

Custom memory handlers are quite common. They are used for different
purposed like performance enhancements, defragmentation strategies or
transactional memory handling.

Some links to these

http://www.nedprod.com/programs/portable/nedmalloc/index.html
http://www.cs.umass.edu/~emery/hoard/
http://prisms.cs.umass.edu/emery/index.php?page=diehard
http://www.microquill.com/smartheap/index.html
http://www.pf-lug.de/projekte/haya/duma.php
http://www.josuttis.com/cppcode/allocator.html
http://gee.cs.oswego.edu/dl/html/malloc.html

With best regards
Johannes
_______________________________________________
osg-users mailing list
osg-users@openscenegraph.net
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

_______________________________________________
osg-users mailing list
osg-users@openscenegraph.net
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to