PRB: FreeResource Required for Locked Resources on Macintosh
Article ID: 199517
Article Last Modified on 10/24/2003
APPLIES TO
- Microsoft Visual C++ 4.0 Cross Development Edition for Macintosh
- Microsoft Visual C++ 4.0 Cross Development Edition for Macintosh
- Microsoft Visual C++ 4.0 Cross Development Edition for Macintosh
This article was previously published under Q199517
SYMPTOMS
Not calling FreeResource may cause Macintosh applications to leak memory.
CAUSE
Resources on the Macintosh are fairly similar to Windows resources, but there are a few differences.
In Win32 applications, resources do not have to be locked or freed. On Macintosh platforms, however, calling LockResource does actually lock a memory block in the heap. Not calling FreeResource causes that block to remain locked.
RESOLUTION
To avoid memory leaks and heap fragmentation, FreeResource must be used on the Macintosh when a resource loaded using LoadResource is no longer needed.
REFERENCES
Macintosh Porting Guide: Resource Differences
Additional query words: FreeResource LockResource UnlockResource memory leak heap fragmentation
Keywords: kbnoupdate kbprb KB199517