In my root view controller, in my didReceiveMemoryWarning method, I go through a couple data structures (which I keep in a global singleton called DataManager), and ditch the heaviest things I've got--one or maybe two images associated with possibly twenty or thirty or more data records.
Right now I'm going through and setting those to nil. I'm also setting myself a boolean flag so that various view controllers that need this data can easily know to reload. Thusly:
DataManager *data = [DataManager sharedDataManager];
for (Event *event in data.eventList) {
event.image = nil;
event.thumbnail = nil;
}
for (WondrMark *mark in data.wondrMarks) {
mark.image = nil;
}
[DataManager sharedDataManager].cleanedMemory = YES;
Today I'm thinking, though... and I'm not actually sure all that allocated memory is really being freed when I do that. Should I instead release
those images and maybe hit them with a new alloc
and init
when I need them again later?