[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Capacity of NSDictionary

From: Andreas Höschler
Subject: Capacity of NSDictionary
Date: Fri, 1 Feb 2008 18:45:03 +0100

Hi all,

I am using a dictionary to hold business objects. As the key I use a class SOObjectID which basically looks as follows:

@interface SOObjectID : NSObject < NSCopying, SRArchivingProtocol >
   int _identifier; // entity
   int _primaryKey;

- (unsigned int)hash
   return (_primaryKey * 1000 + _identifier);

- (BOOL)isEqual:(id)object
   if (self == object) return YES;
   if ([object isKindOfClass:[SOObjectID class]])
return ([(SOObjectID *)object identifier] == _identifier && [(SOObjectID *)object primaryKey] == _primaryKey);
   else return NO;

I am hitting a serious performance problem when holding many objects in the dictionary. Currently I am running a test with 3 GB of data loaded into the process (running under Solaris 10) and it's getting slow as hell. The machine has 16 GB of RAM so swapping is not an issue. I know that the above is not the cutest way to hold great chunks of data. I already wondered whether it would be a good idea to replace the NSDictionary with something that uses a binary tree to hold the data. However, since this is not done in a couple of minutes I would appreciate to find an easier solution for now. How many objects should a dictionary be able to handle with reasonable performance? Anything I could do in my SOGlobalID class to improve performance?

Thanks a lot!



reply via email to

[Prev in Thread] Current Thread [Next in Thread]