Re: cocoa-dev digest, Vol 2 #2086 - 11 msgs
Re: cocoa-dev digest, Vol 2 #2086 - 11 msgs
- Subject: Re: cocoa-dev digest, Vol 2 #2086 - 11 msgs
- From: Lorenzo Puleo <email@hidden>
- Date: Tue, 18 Mar 2003 18:36:42 +0100
Hi,
I tried what you say, but the same, at the end of the routine, the unix
"top" command tells me that RSIZE and Free Mem don't come back to the
initial values. I exactly wrote:
- (IBAction)MyLoop:(id)sender
{
NSAutoreleasePool* aPool = [[NSAutoreleasePool alloc] init];
int count = 500000;
int index = 0;
NSMutableArray* anArray = [NSMutableArray arrayWithCapacity: count];
for ( index = 0; index < count; index++ )
{
[anArray addObject:[NSString stringWithFormat: @"Don't leak, step
%d", index]];
}
[aPool release];
}
Look here below what the top command reported:
- The free memory is 328M before running the routine "MyLoop",
and 302M at the end.
- The RSIZE is 8.57M before running the routine "MyLoop",
and 33.2M at the end.
Before running the routine
===========================
Processes: 43 total, 2 running, 41 sleeping... 103 threads
16:11:18
Load Avg: 0.56, 0.40, 0.34 CPU usage: 52.6% user, 17.5% sys, 29.8% idl
SharedLibs: num = 90, resident = 20.5M code, 2.61M data, 7.36M LinkEdit
MemRegions: num = 2392, resident = 16.8M + 8.26M private, 35.2M shared
PhysMem: 46.9M wired, 56.5M active, 81.1M inactive, 184M used, 328M free
VM: 2.00G + 51.8M 5047(1) pageins, 0(0) pageouts
PID COMMAND %CPU TIME #TH #PRTS #MREGS RPRVT RSHRD RSIZE VSIZE
409 MyApp 0.0% 0:00.99 1 60 130 3.00M 7.04M 8.57M 105M
After running the routine
===========================
Processes: 43 total, 2 running, 41 sleeping... 104 threads
16:11:50
Load Avg: 0.25, 0.35, 0.31 CPU usage: 2.9% user, 3.8% sys, 93.3% idle
SharedLibs: num = 90, resident = 20.7M code, 2.61M data, 7.36M LinkEdit
MemRegions: num = 2512, resident = 41.7M + 8.26M private, 35.5M shared
PhysMem: 47.1M wired, 56.9M active, 106M inactive, 210M used, 302M free
VM: 2.03G + 51.8M 5109(0) pageins, 0(0) pageouts
PID COMMAND %CPU TIME #TH #PRTS #MREGS RPRVT RSHRD RSIZE VSIZE
409 MyApp 0.0% 0:05.77 1 60 229 27.7M 7.14M 33.2M 130M
So, one of the following cases should be true:
A) You and me and other developers wrote a wrong code.
B) The "top" command reports wrong data.
C) The Free Mem and RSIZE values are not the values I have to check.
D) I have set some wrong Build Setting parameter in my application.
Any idea?
Best Regards
--
Lorenzo Puleo
email: email@hidden
>
Message: 6
>
Date: Tue, 18 Mar 2003 12:43:08 +0100
>
Subject: Re: NSAutoreleasePool: how does it really work?
>
From: petite_abeille <email@hidden>
>
To: <email@hidden>
>
>
Your array is retaining your strings. The pool allocation/deallocation
>
inside the loop is frivolous.
>
>
If for some reasons you want to micromanage your memory pool, try:
>
>
NSAutoreleasePool* aPool = [[NSAutoreleasePool alloc] init];
>
int count = 500000;
>
int index = 0;
>
NSMutableArray* anArray = [NSMutableArray arrayWithCapacity: count];
>
>
for ( index = 0; index < count; index++ )
>
{
>
[anArray addObject:[NSString stringWithFormat: @"Don't leak, step
>
%d", index]];
>
}
>
>
[aPool release];
_______________________________________________
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.