Re: exiting


[ Follow Ups ] [ Post Followup ] [ CS2704 Web Discussion Board ] [ FAQ ]

Posted by William D McQuain on December 02, 2001 at 14:56:43:

In Reply to: exiting posted by adam on December 02, 2001 at 00:14:34:

: i'm not sure if this will even be relevant...if the script files dont include an "exit" command. anyway, if they do and we invoke one, the spec says it must delete all dynamically allocated memory. i was wondering if

: exit(0)

Invoking exit() will abort the program. AFAIK there is no guarantee that destructors will fire in that case.

Regarding memory deallocation, the OS should reclaim all resources held by a process when that process terminates. So there should not be a memory leak even if exit() is invoked.

Of course in some cases (but probably not this one) the destructor may have additional work to do besides just deallocation, including logging data to file and that would be lost.

In any case, any class that allocates memory dynamically should provide a destructor to deallocate it. If the client code causes the destructor to not fire, that's the client's error, not that of the class.

: would invoke destructors or skip that somehow.




Follow Ups:



Post a Followup

Name:
E-Mail:

Subject:

Comments:

Optional Link URL:
Link Title:
Optional Image URL:


[ Follow Ups ] [ Post Followup ] [ CS2704 Web Discussion Board ] [ FAQ ]