Release Handle manually

Hi:
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,
Shawn

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.

HTH,

Patrik Müller

Shawn Yang's picture

Hi:
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.

Sincerely
Shawn

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 3.7.3.2 4

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