I have a NSCollectionView
that I populate using [collectionView setContent:data];
where data
is a NSArray
filled with objects all of the same custom NSObject
subclass. The item prototype of the collection view is a standard NSCollectionViewItem
, not subclassed. The collection item's view is populated using bindings from my NSObject
subclass.
Now to th开发者_高级运维e problem, when analyzing my app using heapshots I see that there is a huge increase in memory when opening the window with the collection view. Instruments pinpoints this memory increase to the [collectionView setContent:data];
line. This memory is never reclaimed. Any ideas?
EDIT: I access the data object like this:
NSArray *data = [[[[MWWeatherController sharedInstance] cachedData] objectForKey:[NSString stringWithFormat:@"%u",index]] objectForKey:@"daily"];
Have you made the ViewController for the CollectionView KVO compliant?
Has the XIB for the CollectionView an ArrayController?
Bind the CollectionView of the XIB to the arrangedObjects of the ArrayController and set the Items through your ViewController method e.g. setMyCustomObjectsArray, that again sets the array that is observed by the ArrayController.
Make sure you release everything correctly in your custom object's dealloc method too.
I think you are not releasing data in your scope ... if you own the 'data' object make sure you release it.
Some query to answer it better --
- How you allocate 'data'?
- Who is releasing it?
- [collectionView setContent:data]; more code snippet around this line
精彩评论