Debugging reference counting - Graphics
This is a discussion on Debugging reference counting - Graphics ; Hi,
The reference counting in Open Inventor is neat but it'd be nice to get more
information about it at the programming level for debugging.
For example is there any way to get the current reference count of an
object?
...
-
Debugging reference counting
Hi,
The reference counting in Open Inventor is neat but it'd be nice to get more
information about it at the programming level for debugging.
For example is there any way to get the current reference count of an
object?
We have code wrappers around Open Inventor and religiously ref() at
construction and unref() at destruction BUT other things can cause reference
counts to increment (field connections, counting on engines etc.)
If there aren't any SoDB style methods or environment variables for
debugging ref counts (or finding out when objects are actually destroyed by
the database) can anyone suggest any other useful ways of actually checking
that objects are being correctly deleted?
Is one unref() too many guaranteed to fail at that point? (or would this
simply result in a double deletion style problem where the results are
undefined?)
Thanks for any help.
fletch@picknowl.com.au
-
Re: Debugging reference counting
"Fletch" <fletch@picknowl.com.au> writes:
> The reference counting in Open Inventor is neat but it'd be nice to get more
> information about it at the programming level for debugging.
You can use SoBase::setTraceRefs(). This will produce lots of
debug information though.
> For example is there any way to get the current reference count of an
> object?
Yes. SoBase::getRefCount()
> We have code wrappers around Open Inventor and religiously ref() at
> construction and unref() at destruction BUT other things can cause reference
> counts to increment (field connections, counting on engines etc.)
>
> If there aren't any SoDB style methods or environment variables for
> debugging ref counts (or finding out when objects are actually destroyed by
> the database) can anyone suggest any other useful ways of actually checking
> that objects are being correctly deleted?
If you want to know when a specific node is destroyed, you can attach
an SoNodeSensor to it and use SoDataSensor::setDeleteCallback() to
set the callback to be called when an object is destructed. The
callback will be called from SoBase::destroy(), which is a virtual
function that is called when the reference count reaces zero (the
callback is called right before "delete this").
> Is one unref() too many guaranteed to fail at that point? (or would this
> simply result in a double deletion style problem where the results are
> undefined?)
If you use Coin, we've introduced an ALIVE_PATTERN in SoBase. This
pattern is checked in SoBase::ref() and unref(), and you'll get an
assert failure if you attempt to unref() an object that is already
deleted.
I'm not sure if TGS or SGI Inventor tries to detect when unref()
is called on a deleted object.
Peder
Similar Threads
-
By Application Development in forum CSharp
Replies: 9
Last Post: 12-02-2007, 06:23 PM
-
By Application Development in forum Idl-pvwave
Replies: 2
Last Post: 09-20-2007, 03:13 PM
-
By Application Development in forum c++
Replies: 2
Last Post: 07-30-2007, 07:36 AM
-
By Application Development in forum C
Replies: 7
Last Post: 08-08-2006, 03:03 PM
-
By Application Development in forum Perl
Replies: 13
Last Post: 12-22-2005, 07:35 AM