ADC Home > Reference Library > Technical Q&As > Legacy Documents > Mac OS 9 & Earlier >

Legacy Documentclose button

Important: This document is part of the Legacy section of the ADC Reference Library. This information should not be used for new development.

Current information on this Reference Library topic can be found here:

Preventing Memory Leaks

Q: When NewPtr is used to allocate a block of memory in the application heap, is it necessary to use DisposePtr to release this block when the program terminates?

A: No. All memory allocated by an application in the application heap (with NewPtr, NewHandle, NewPtrClear, or NewHandleClear) is released by the Process Manager when the application terminates, and the application's heap zone is destroyed. This means that you do not explicitly have to call DisposePtr to release blocks of memory you allocate with a NewPtr call before the application exits.

If your application allocates memory in the system heap, then it must deallocate it. Otherwise, leaks occur. Calls that allocate memory in the system heap include NewHandleSys, NewHandleSysClear, NewPtrSys, and NewPtrSysClear.

[May 01 1995]


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.