FROM : Jamie Curmi
DATE : Sat Jan 18 22:32:36 2003
Hi All,
I should point out, every time this is called, more leaks occur. It
isn't just the first call of [NSImage imageNamed:@"Connected"] that
leaks (I realise that gets cached). It appears that every call of
copy, followed by the release, ends up with more memory leaked.
MallocDebug shows the leak - and it increases with each call.
Similarly "top" shows the vsize increasing with each call.
Am I missing something here?
Jamie
On Sunday, January 19, 2003, at 03:50 AM, j o a r wrote:
> *When* does it leak? You create a temporary, autoreleased, object like
> this:
>
> [NSImage imageNamed:@"Connected"]
>
> ...then you make a copy of that object. Now you have two objects, one
> autoreleased and one with a retain count of one. After that you
> release the copied object, but the autoreleased object will remain for
> the duration of the current event loop. If you sample directly after
> releasing the copied object you would notice that you still have one
> object around - and this is as it should.
>
> If you create a lot of autoreleased objects in a loop, you might
> consider using local autorelease pools. There is plenty of
> documentation on that topic, both in the docs from Apple, in the list
> archives, and online - notably on stepwise.com.
>
> j o a r
>
>
> On Saturday, Jan 18, 2003, at 13:59 Europe/Stockholm, Jamie Curmi
> wrote:
>
>> Maybe this is a stupid question. Could someone tell me why the
>> following code leaks memory (under 10.2.3)?
>>
>> NSImage * icon = [[NSImage imageNamed:@"Connected"] copy];
>> [icon release];
>>
>> Of course, that isn't what my program does. But my program leaks,
>> and I've simplified it down to that. I thought that the "release"
>> would cleanup the copy of the icon I've made, but that doesn't seem
>> to be the case.
_______________________________________________
cocoa-dev mailing list | <email_removed>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
DATE : Sat Jan 18 22:32:36 2003
Hi All,
I should point out, every time this is called, more leaks occur. It
isn't just the first call of [NSImage imageNamed:@"Connected"] that
leaks (I realise that gets cached). It appears that every call of
copy, followed by the release, ends up with more memory leaked.
MallocDebug shows the leak - and it increases with each call.
Similarly "top" shows the vsize increasing with each call.
Am I missing something here?
Jamie
On Sunday, January 19, 2003, at 03:50 AM, j o a r wrote:
> *When* does it leak? You create a temporary, autoreleased, object like
> this:
>
> [NSImage imageNamed:@"Connected"]
>
> ...then you make a copy of that object. Now you have two objects, one
> autoreleased and one with a retain count of one. After that you
> release the copied object, but the autoreleased object will remain for
> the duration of the current event loop. If you sample directly after
> releasing the copied object you would notice that you still have one
> object around - and this is as it should.
>
> If you create a lot of autoreleased objects in a loop, you might
> consider using local autorelease pools. There is plenty of
> documentation on that topic, both in the docs from Apple, in the list
> archives, and online - notably on stepwise.com.
>
> j o a r
>
>
> On Saturday, Jan 18, 2003, at 13:59 Europe/Stockholm, Jamie Curmi
> wrote:
>
>> Maybe this is a stupid question. Could someone tell me why the
>> following code leaks memory (under 10.2.3)?
>>
>> NSImage * icon = [[NSImage imageNamed:@"Connected"] copy];
>> [icon release];
>>
>> Of course, that isn't what my program does. But my program leaks,
>> and I've simplified it down to that. I thought that the "release"
>> would cleanup the copy of the icon I've made, but that doesn't seem
>> to be the case.
_______________________________________________
cocoa-dev mailing list | <email_removed>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
| Related mails | Author | Date |
|---|---|---|
| Jamie Curmi | Jan 18, 13:59 | |
| j o a r | Jan 18, 17:50 | |
| Jamie Curmi | Jan 18, 22:32 | |
| j o a r | Jan 18, 23:04 | |
| j o a r | Jan 18, 23:21 | |
| Jamie Curmi | Jan 18, 23:27 | |
| j o a r | Jan 19, 00:48 | |
| Andreas Mayer | Jan 19, 01:23 | |
| j o a r | Jan 19, 01:46 | |
| Jamie Curmi | Jan 19, 02:04 | |
| j o a r | Jan 19, 02:10 | |
| Jamie Curmi | Jan 19, 04:27 |






Cocoa mail archive

