I’ve some memory issues with a view controller that contains a text field.
Brief summary:
- Clicking on a button my application modally presents a
UIViewController(that I will call “VC1”). - From VC1 the user can optionally open (using
pushViewController) aUITableViewController(“VC2”) and turn back. - From VC1 the user can optionally open (using
pushViewController) aUIViewController(“VC3”) and turn back. - Finally the user can dismiss VC1
VC2 and VC2 are referenced in VC1 as properties and they have to remain in memory. When the user dismisses VC1 then I release all.
VC3 contains a simple view with only one UITextField that becomeFirstResponder when viewWillAppear is invoked.
Issues:
When I open VC1 and then VC2, turn back and dismiss: it’s all ok, the application returns to the same initial amount of “Live bytes” (that is 1,20MB). When I open VC1 and then VC3, bytes become 2MB. When I write something inside the text field allocations rise to 2,50MB
-
In this moment Instruments discovers a memory leak of 16byte with ProofReader as Responsible Library and PRRfInit as Responsible Caller
-
After turning back to VC1 and dismissing, the allocations remain to 2,50MB
Ordering by category in Instruments I checked that VC1, VC2 and VC3 have 0 live bytes, but the overall remains to 2,50MB
Is also involved the keyboard?
I’m assuming that you’re testing on the device, not the simulator – the simulator produces incorrect results.
The total memory used by your app is fairly meaningless as a measure of memory leaks – the iPhone will try to cache as much data as it can while there is free memory – it will load libraries and leave them in memory in case you are going to use them again. It’s only an issue when you start to run out and then it will sort it out for you.
And a 16byte leak from a library is fairly irrelevent (assuming it only happens once) – Apple’s libraries end up leaking more than that in my experience.
There are many better ways to spend your time 😉
PS Is ProofReader a library you have included or one that’s part of Apple’s SDK?