[futurebasic] Re: [FB] Objective C - ivar dealoc from memory

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : March 2017 : Group Archive : Group : All Groups

From: Eugen Rosu <eugen.rosu@...>
Date: Wed, 8 Mar 2017 20:24:39 +0200
Hello,

Yes, i use ARC now, but @autoreleasepool does not work like i belive it would work.

> On 08 Mar 2017, at 15:38, Ken Shmidheiser <kshmidheiser@...> wrote:
> 
> Victor wrote:
> 
>> If you want to reproduce a memory hog, please insert in the NSMutableArray a NSDictionary like:
> 
> 
> Victor,
> 
> I think you may have meant "insert an NSDictionary into the NSMutableArray.”

Yes. I insert 150.000 NSDictionary items into the NSMutableArray.

The NSMutableArray is an instance variable not a local one.
My application scan recursively the NSHomeDirectory() and for every file found i insert into the NSMutableArray an itemDict (NSDictionary *itemDict) with 10 keys and values,
like file name, file extension, created date, modified date, full path, path without file name, file id (from the macOS file manager).
That for statement i provided is pretty much like the strings and values i have from the scan.

> 
> I have not had time to check for memory use, but in the demo below -- which I have limited to 15000 instead of 150000 iterations for the sake of time -- it appears that most of the processing time is used by NSLog to print the results. Run the code without NSLog and the processing is almost instantaneous. Maybe someone here can run a memory test.

On my computer are ~= 150.000 files found.
After that recursive scan, mymutarr has 108 - 112 MB stored in memory.
But i did not found a solution how to release it, yet!
I don’t need forever that variable in my application.

NSLog is slow, but the memory issue is not NSLog.

> 
> Also, the code sample you posted uses strings for values. I elected to use numerical values since I wasn't quite sure of exactly what kind of objects you are storing as values in your dictionary.
> 
> Ken
> 
> include "NSLog.incl"
> 
> BeginCCode
> NSMutableArray *mymutarr = [[NSMutableArray alloc] init];
> 
> for ( int i = 0; i < 15000; i++ )
> {
>  NSNumber *item = [NSNumber numberWithInt: i];
>  NSDictionary *itemDict = @{@"key1": item, @"key2": @2, @"key3": @3, @"key4": @4, @"key5": @5};
>  [item release];
>  [mymutarr addObject:itemDict];
> }
> 
> NSLog( @"object = %@", mymutarr );
> [mymutarr release];
> 
> EndC
> 
> RunApplicationEventLoop()