Re: NSAutoreleasePool: how does it really work?
Re: NSAutoreleasePool: how does it really work?
- Subject: Re: NSAutoreleasePool: how does it really work?
- From: Lorenzo Puleo <email@hidden>
- Date: Tue, 18 Mar 2003 12:20:34 +0100
Hi Oleg,
I tried both the samples you granted (MyLoop1 and MyLoop2), and they
produced the same lack of memory.
Before launching the routine I have:
PID COMMAND %CPU TIME #TH #PRTS #MREGS RPRVT RSHRD RSIZE VSIZE
1301 MyApp 0.0% 0:01.07 1 60 138 3.03M 7.39M 8.61M 105M
And after my routine ends I get:
PID COMMAND %CPU TIME #TH #PRTS #MREGS RPRVT RSHRD RSIZE VSIZE
1301 MyApp 0.0% 0:06.88 1 60 237 27.7M 7.41M 33.3M+ 130M
The RSIZE value remains at 33.3M and never goes down. Sure I don't do
anything else, either before and after the routine. I also tried to attach
this routine to the button directly as:
- (IBAction)MyLoop2:(id)sender
{
int i;
xArray = [NSMutableArray arrayWithCapacity:0];
for(i = 0; i < 500000; i++){
NSAutoreleasePool *myPool = [[NSAutoreleasePool alloc] init];
[xArray addObject:[NSString stringWithFormat:@"Do leak, step %d",
i]];
[myPool release];
}
[xArray removeAllObjects];
}
Any idea?
Best Regards
--
Lorenzo Puleo
email: email@hidden
>
From: Oleg Svirgstin <email@hidden>
>
Date: Tue, 18 Mar 2003 13:15:26 +0300
>
To: <email@hidden>
>
Cc: Lorenzo Puleo <email@hidden>
>
Subject: Re: NSAutoreleasePool: how does it really work?
>
>
I would suggest such experimental pair:
>
>
> ===============================
>
> - (void)MyLoop1
>
> {
>
> int i;
>
> xArray = [NSMutableArray arrayWithCapacity:0];
>
> for(i = 0; i < 500000; i++)
>
> {
>
> NSAutoreleasePool *myPool = [[NSAutoreleasePool alloc] init];
>
> [xArray addObject:[NSString stringWithFormat:@"Do leak, step %d", i]];
>
> [myPool release];
>
> }
>
> [xArray removeAllObjects];
>
> }
>
> ===============================
>
>
against
>
>
> ===============================
>
> - (void)MyLoop2
>
> {
>
> int i;
>
> xArray = [NSMutableArray arrayWithCapacity:0];
>
> for(i = 0; i < 500000; i++){
>
> [xArray addObject:[NSString stringWithFormat:@"Don\'t leak, step %d", i]];
>
> }
>
> [xArray removeAllObjects];
>
> }
>
> ===============================
>
>
and then compare results. IMHO, they BOTH should not leak. :(
>
>
Regards
>
Oleg
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.