Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Home » Tip Bank » C++
Language: C++
Expertise: All
Apr 30, 2001



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Verifying a Destructor's Invocation

Conceptually, destructors of global objects are called after main() has exited. For this reason, many debugging and memory checking tools are confused and report phantom memory leaks or warn about destructors that allegedly don't execute. In most cases, you can ignore these false alarms. For instance, when they are reported on the iostream objects. However, if you want to verify that destructors of user-defined global objects are called, you can create a file in the destructor and examine whether it was created after the program terminates. Alternatively, you can emit a beep from the destructor.
Danny Kalev
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date