Release Handle manually

I declared a Public:\"Handle(AIS_InteractiveObject) aObject\" in header file(Dialog). After destroying the Dialog, I recall the dialog, again. I find that aObject stills keep data. How can I release manually the object before destroying the dialog? Or it should be released by itself because of "Handle". If it is true. Why doesn't the aObject keep Null? Thanks a lot.

PS. I have tried to use VC++ way to "delete aObject". It crashed.

Best regards,

Patrik Mueller's picture

Hi Shawn,

you can do a "Nullify" to your handle when destroying the dialog. After that you can check the "IsNull()" for the handle.


Patrik Müller

Shawn Yang's picture

Thanks for your answer. But, it is not exactly I want. The Nullify function only clear the data in the "aObject" variable; not take off all records(ex. address). It still keep space in system. I think it is not the problem of OPENCASCADE; It is VC++. I think when we declare some variables in the header file. After running program, I think all variables has been assigned space(address) in system. I have tested it. Never matter I reboot the computer or rebuild the program. I always get the same address.


Ivan Fontaine's picture

From a C++ point of view, deleting an object doesn't alter
its content. It just tells the memory manager that the pointed memory is available.
After deletion the memory area used by the object is said to be "undefined". Most of the time the area is simply left untouched.

If you want to alter the object, you must modify its destructor.
But of course, an object can only be destroyed once.

Cfr ANSI C++ standard 4

At the time storage is deallocated, the values
of any pointers that refer to that deallocated storage become indeter-