views:

56

answers:

3

I am new to programming (learned how to write apps a few months ago) and recently wrote an app that crashes every time after about 5 minutes with several 'Received memory warning. Level=1' warnings. While testing with instruments, I have been unable to detect any leaks and I'm fairly confident I'm releasing the objects correctly so I suspect the memory problems stem from the large number of png images I use (around 80). I've tried changing from the -imageNamed method to -imageWithContentsOfFile and saw no real improvement. If anyone could offer any tips I would really appreciate it since I am completely stuck.

A: 

Running out of memory does not necessarily imply memory leaks. It could mean that you've asked for too much memory at once. In your case, you're probably trying to create too many UIImage objects that all exist simultaneously. Without seeing a lot more of your code, there's not much to say except try and find a way to use fewer images at the same time.

Shaggy Frog
A: 

Supposedly UIImages which you load using imageNamed offload their contents when possible, if they receive memory warnings. UIImage Reference, see Images and Memory Management That would leave only a very small, empty UIImage container. So I suspect that you have some other problem.

Check for any loop within your program and make sure it doesn't leak in some way.

mvds
A: 

also remember that PNGs on disk are much smaller than the corresponding image in memory. if your PNGs are large, you could just be using up too much memory. maybe you can delay-load images to make your footprint smaller.

gga80