Reputation: 1266
I am working on an iOS 5 project and have run into a severe performance problem, reducing my app to <10fps consistently. The time profiling tool has identified a call to objc::DenseMap
which seems to have to do with the retain/release/autorelease system in the Objective-C runtime. This call is taking a massive portion of processing time and I was wondering if anyone has any pointers for resolving this penalty and/or ways of avoiding this issue. I suspect it has something to do with the NSMutableArrays, NSMutableSets, and other mutable collections I am using to manage objects per frame. Any advice or insight into tracking this down and resolving it would be much appreciated. Below is everything in the trace that looked important or pertinent:
Running Time Self Symbol Name
1426.0ms 7.2% 1426.0 objc::DenseMap<objc_object*, unsigned long, true, objc::DenseMapInfo<objc_object*>, objc::DenseMapInfo<unsigned long> >::LookupBucketFor(objc_object* const&, std::pair<objc_object*, unsigned long>*&) const
817.0ms 4.1% 0.0 objc::DenseMap<objc_object*, unsigned long, true, objc::DenseMapInfo<objc_object*>, objc::DenseMapInfo<unsigned long> >::FindAndConstruct(objc_object* const&)
817.0ms 4.1% 0.0 _objc_rootRetain
817.0ms 4.1% 0.0 -[NSObject retain]
773.0ms 3.9% 0.0 objc_retain
28.0ms 0.1% 0.0 -[NSMutableArray removeObject:]
11.0ms 0.0% 0.0 CFRetain
580.0ms 2.9% 0.0 objc::DenseMap<objc_object*, unsigned long, true, objc::DenseMapInfo<objc_object*>, objc::DenseMapInfo<unsigned long> >::find(objc_object* const&)
580.0ms 2.9% 0.0 _objc_rootReleaseWasZero
580.0ms 2.9% 0.0 _objc_rootRelease
562.0ms 2.8% 0.0 objc_release
1.0ms 0.0% 0.0 CFRelease
19.0ms 0.0% 0.0 objc::DenseMap<objc_object*, unsigned long, true, objc::DenseMapInfo<objc_object*>, objc::DenseMapInfo<unsigned long> >::grow(unsigned int)
19.0ms 0.0% 0.0 objc::DenseMap<objc_object*, unsigned long, true, objc::DenseMapInfo<objc_object*>, objc::DenseMapInfo<unsigned long> >::InsertIntoBucket(objc_object* const&, unsigned long const&, std::pair<objc_object*, unsigned long>*)
19.0ms 0.0% 0.0 objc::DenseMap<objc_object*, unsigned long, true, objc::DenseMapInfo<objc_object*>, objc::DenseMapInfo<unsigned long> >::FindAndConstruct(objc_object* const&)
19.0ms 0.0% 0.0 _objc_rootRetain
19.0ms 0.0% 0.0 -[NSObject retain]
15.0ms 0.0% 0.0 objc_retain
4.0ms 0.0% 0.0 -[NSMutableArray removeObject:]
5.0ms 0.0% 0.0 _objc_rootRetain
5.0ms 0.0% 0.0 -[NSObject retain]
4.0ms 0.0% 0.0 objc_retain
3.0ms 0.0% 0.0 objc_retainAutoreleasedReturnValue
1.0ms 0.0% 0.0 -[NSMutableArray removeObject:]
3.0ms 0.0% 0.0 _objc_rootReleaseWasZero
3.0ms 0.0% 0.0 _objc_rootRelease
3.0ms 0.0% 0.0 objc_release
2.0ms 0.0% 0.0 objc::DenseMap<objc_object*, unsigned long, true, objc::DenseMapInfo<objc_object*>, objc::DenseMapInfo<unsigned long> >::erase(objc_object* const&)
2.0ms 0.0% 0.0 objc_clear_deallocating
2.0ms 0.0% 0.0 objc_destructInstance
2.0ms 0.0% 0.0 CFRelease
Upvotes: 1
Views: 1320
Reputation: 162712
Filter out the system libraries from the performance analysis and see what that indicates. You are looking at the wrong end of the stack.
Your code, typically, is a relatively thin veneer that glues together the system frameworks in whatever way is necessary for you to create your specific app. A performance problem like this most often indicates that your apps implementation is algorithmically non-performant; maybe you are re-cacluating stuff too often, maybe you are emptying/filling collections when you could be using a cache, etc...
Upvotes: 3