views:

131

answers:

2

Hi all, 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) a UITableViewController ("VC2") and turn back.
From VC1 the user can optionally open (using pushViewController) a UIViewController ("VC3") and turn back.
...and 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

1) In this moment Instruments discovers a memory leak of 16byte with ProofReader as Responsible Library and PRRfInit as Responsible Caller

2) 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?

A: 

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?

deanWombourne
Emh... for now I'm just developing and testing on the simulator due to the unavailability of a device...I will try to test on a real device as soon as possible. What seemed strange to me was why pop the keyboard and write in the text field implies an increase of 1MB that is never released.PS: I think ProofReader is a part of SDK
That 1MB is probably the UI for the keyboard? It will keep it in memory incase you want to display it again - if it's already in memory it can respond faster! If it needs the memory it can release it later - it's not a leak, it's an optimization!
deanWombourne
A: 

I hav the same problem, but i'm testing on a device, if this info is for any use

w4nderlust