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

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

From: Ken Shmidheiser <kshmidheiser@...>
Date: Wed, 8 Mar 2017 08:38:28 -0500
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."

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.

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()