Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Memory Leakage in Appearance Manager
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Memory Leakage in Appearance Manager



I Wrote:
>> To get around this I am instead setting the "contentType" for the bevel
>> button control to kControlContentPictHandle as follows:
<snip>
>> Now when I dispose of the window the PICT data handle is left in memory...

Pietrzak, Bryan wrote:
> Yes, this is documented in the comments in ControlDefinitions.h

Thanks. I found the documentation. Now I know how to solve it. I just read
the 'PICT' resource as required and mark it non-purgeable and it will remain
available for all buttons that need to use it.

I did come across one little gotcha though. I have some buttons who's
contents are of type "kControlContentCIconHandle" as follows:

controlContent.contentType = kControlContentCIconHandle;
controlContent.u.cIconHandle = (CIconHandle) theIconHandle;
SetControlData (controlHdl, 0, kControlBevelButtonContentTag,
sizeof(ControlButtonContentInfo), (Ptr)(&controlContent))

where "theIconHandle" is assigned using a call to "GetCIcon()".

Now GetCIcon, unlike GetPicture, does not return a resource handle, but
rather uses the information contained in the 'cicn' resource to create a
handle to a colour Icon description which must be disposed of using
DisposeCIcon(). In this case I needed fill an array at startup time with the
CIconHandle for any colour Icons I use.

Perhaps GetCIcon() should be renamed to something like GetCIconDescription()
to prevent this type of confusion. And if this could behave more like
GetPicture where multiple calls with the same ID would return the same
handle, then so much the better.

It's an ugly solution (I don't like leaving things lying around for
ExitToShell to clean up for me) but it works and my application has no
memory leaks.

Thanks for your help Bryan.

Sean.




Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.