Is this considered memory leak?

The general rule, only objects allocated in the free store can cause memory leaks. But objects created in the stack doesn't.

Here is my doubt,

int main()
    {
      myclass x;

      ...

      throw;

      ...
    }

If throw is not handled, it calls, terminate(), which in turn calls abort() and crashes the application. At this time, the objects in the stack are not destoryed (The destructor is not invoked).

My understanding is "When the application terminates (either by abort or by normal exit), it frees all the memory that was allocated for the application". Thus this cannot be considered as memory leak.

Am I correct?

5
задан nsivakr 25 August 2010 в 20:53
поделиться