Thu, 03/18/2004 - 01:58
Hi everybody,
I'm having problems with the function Remove() of an Interactive Context. In my application I create a new AIS_Shape using the new operator and storing it for later use in a Handle(AIS_Shape). After that the refernce counter of the handle is 1. After displaying the object in my AIS_InteractiveContext using the Display() function the reference counter is increased to 3. After some operations I want to free the allocated memory for the AIS_Shape object again. This is done I think using the Remove function. Then I force the release of the handle by calling the Nullify() function of the Handle(AIS_Shape), which first decrements the reference counter by one and then checks whether the counter is 0. But it is not 0, during debugging I found that calling Remove() decreases the reference counter only by 1 from 3 to 2, so that the later call of Nullify results in a reference counter of 1. Because of this the memory is not released. It seems to me that somehow the Interactice Context still owns a reference to my handle.
So my questions is am I doing somthing wrong, or is there any other way to force the release of memory of an interactive object.
Thanks for your help,
Sven Jungnickel
Thu, 03/18/2004 - 14:29
Hi Sven,
Well, this won't be any help to you at all I'm afraid, but after I saw your question I checked the behaviour of the reference counters for objects I am calling Remove() on. I found that the reference counter drops from 3 to 1 after calling Remove(). i.e. it is working correctly. I would say that you are not doing something wrong, and maybe something odd is happening in your code. I haven't updated to OCC 5.1 yet, I'm still on 5.0. Which version are you using?
Regards,
Neil
Thu, 03/18/2004 - 15:43
Hi Neil,
I'm also on version 5.0 and I don't have a clue what's the reason for this behaviour. The reason I do all the stuff is that my AIS_Shape object is recalculated and I want to discard the old one before assigning the new object. Maybe the AIS_Shape::Set() function automatically does this, but I can only find the function prototype...I'm still searching the source for this function...
But thanks for your answer. Now I know that normally it is the correct way.
Sven
Sun, 05/13/2007 - 05:14
Hi everybody,
Sun, 05/13/2007 - 05:18
It seems to me I've got the same behavior on 6.2 version. What's to do?
Thanks, Ivan.
Sun, 05/13/2007 - 05:50
Well, I found the solution here:
http://www.opencascade.org/org/forum/thread_5730/
Many thanks to Sangsu Lee, it works fine.
Best regards, Ivan.