Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

harryslotwiner

macrumors newbie
Original poster
Mar 28, 2012
19
0
Hello,
I have an application in which I have an array of around 200 Labels, 400 Image Views, 600 Strings and 200 Text Views. So in short a lot of views, and this is causing some memory issues.

After about 2 minutes of intimate use a.k.a. interaction with the views the app is closed due to using to much memory.

How can I fix this?
 
My guess is that you have a scrolling view with all those elements. You need to reuse the elements as they leave the screen. IE, if 10 fit on the screen at a time, have 11 of them. As the topmost one gets scrolled off the top of the screen, move it to be the bottom most one (the one about to scroll onto the screen,) and change its contents to make it look like a new label. This is how long scrolling table views like the built in music app are done. (The all songs list can easily have over 10K rows in it, so it recycles like I said and only actually has a dozen or so that just get reused hundreds of times when the user scrolls.)
 
Check Your Image Sizes

Images take the most memory. Make sure your images are not huge, as they only really need to be twice the final size to look nice. If you have fifty foot long images, your wasting memory. Also, are you using automatic reference counting? Most users are on ios 5, so your not really losing anything by taking advantage of this. If you are stubborn, and don't want to use arc, then make sure you are releasing EVERYTHING that you don't need.
 
Last edited by a moderator:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.