views:

47

answers:

2

Hi Guys,

I have an iphone application. I am using XCode 3.2.3 and iphone SDK4.

Application is supporting multitasking as of every application built in this version of XCode. My application goes into background and become active without any problem. One thing worth nothing here is that I don't need to store any information which I need when application become active.

Right, here comes the real question. Application works If I don't drain off memory by playing other applications.

For example if I use my application and then use some game applications and then use my application it gives me memory warning level 1 and sometimes level 2 and crash.

Anyone any idea.

Thanks

A: 

Use the debugger to find out more about the crash. The stack trace shows you the place incode where the crash happens.

You can simulate a low memory condition in the simulator using the menu.

Nikolai Ruhe
A: 

According to your comment, it sounds like you might release webData twice. Once during the normal clean-up and then in the clean-up due to low memory.

Ensure that you set the webData variable to nil after releasing it. That way it will be harmless to try to release it a second time. Alternatively you can access it through a property and then allocate it using self.webData = [NSMutableData data] and release it using self.webData = nil

Claus Broch
Thanks Claus. Much appreciated.You are absolutely right. I am releasing webData after connectionDidFinishLoading. What do you recommend in this situation? Should I do something like that [webData release];self.webData = nil;or should I do just self.webData = nil;
Leo
That depends if you are using properties or not. If you are using properties, then self.webData = nil will do the trick. If you are not using properties then you need to set webData = nil after releasing it.
Claus Broch
Hey Claus, Thanks. I am using properties. So I have changed my code accordingly from [webData release]; to self.webData = nil; I have installed the new app on my device. I'll test this throughout the day tomorrow. I'll let you know if I get any issues. Thanks once again. I'll mark the question as answered tomorrow :)
Leo