![]() | Low memory warning. |
|
23 Mar 2009, 21:18
Gary Mortimer (4 posts) |
Hi all, During testing my app keeps shutting down and I’ve used Instruments to diagnose the problem. According to Instruments Object Allocations my ‘Net Bytes’ figure is 2.08 Mb (Created & Still Living). The ‘Overall Bytes’ figure is 47 Mb. I have no leaks being picked up using the leaks intrument. Is my app shutting down due to the ‘Overall Bytes’ figure? I would have thought that ‘Net Bytes’ would be the important value. Could anyone offer any advise/comments? Many thanks |
|
26 Mar 2009, 16:41
Simon Vrdoljak (3 posts) |
Hi Gary, Are you sure that memory usage is the cause of your problem? I’ve had the app that I’m working on shut down many times, and every time it was caused mistakes in my code. At the time I was learning to use C pointers and making a mess of things. Any breakpoint that I set within the method that had the problem wouldn’t get triggered. I had to set a breakpoint before the call to the method to be able to step through my code and find the cause. If you haven’t done so already, add some logging in every DidReceiveMemoryWarning to confirm that memory usage is the cause of your problem. I only mention this because there have been a few times where I’ve misjudged the cause of a problem, and wasted a lot of time going down the wrong path. Regards, |
|
27 Mar 2009, 00:22
Bill Dudney (917 posts) |
Hi Simon, Great advice! Gary – does the console reveal anything interesting (command-shift-r)? If not I’d set breakpoints as Simon suggests and figure out where its really croaking. Good luck and keep us informed of your progress! |
|
02 Apr 2009, 13:30
Gary Mortimer (4 posts) |
Hi Simon & Bill, Thanks for the tips, it was indeed memory and not coding errors. After ten minutes of continuous use I received the low memory warning (which could be seen on the console log) and then a few minutes later my app was forced to close (the forced closure can also be seen in the console log). The Object Allocation tool is useful but the total/net bytes figures can be very misleading. When I fired up the Activity Monitor tool and looked at the real memory being used it was “much” higher than reported by the Object Allocations tool. During startup my app averages around 3 Mb, navigating up and down different legs of the application greatly increased this figure. Although I was releasing the correct objects and their associated deallocs were being called, the application always seemed to hold on to quite a large portion of memory which I really couldn’t (and still can’t) fully understand. Long story short. I used Object Allocations, Activity Monitor and the Leaks tools to get very aggressive with clearing things (view hierarchies) down. It was hard work, lots of testing, re-writing portions of code, but I got to a stage where I’m very happy with it. It now holds up very well under testing, no crashes, memory usage acceptable, etc… I submitted it to the App store on March 27th, I’m still waiting for approval. Its a business application so it’ll be interesting to see how long the approval takes. Thanks for the book Bill, it really was a great help during the enjoyable but steep learning curve of iPhone development. Many Thanks |
|
24 Apr 2009, 07:33
Shoaib Raza (15 posts) |
Hi Bill, Currently I am facing a big problem with Memory Management. I have posted a question earlier related to Google Map. I wasn’t able to draw polylines at google map but now I have achieved it. I have created an app which continuously record my location in SQL Lite Db. Now to view my stored location, it loads all the transactions and then by javascript it draws the polylines to show the travelled route over the google map. Everything runs perfectly. But a problem is coming, when I am zooming in maximum and then rolling the map by touch. i.e. Navigating to polyline to view my travelled route closely. It works for 3-4 touches then it shows Low Memory warning as I caught the memory warning in didReceiveMemoryWarning. Now my question is how to handle it? I wanted to see my travelled route closely and in case of memory warning how can I reload it so that user won’t be able to wait long or app crash? The Low Memory warning is coming only after I draw polylines over the Google Map otherwise it runs smoothly. It is fine with me that I can set UIWebview=nil and then assign the webpage to it. but how? I need your guidance and suggestion. In any case, if you want to see my app with code, I am ready to send you. Waiting for your urgent reply. Regards, |
|
24 Apr 2009, 13:06
Bill Dudney (917 posts) |
HI Shoaib, I’m really sorry but I know very little about the web side. I have done virtually nothing real in javascript and I’m just not sure how to help with this. Generally when you get a memory warning you need to free objects. Is it possible for you to free objects in javascript? Can you force garbage collection? Also can you lazily draw the path, instead of drawing the whole thing at once? Sorry but this is all just guesses. Good luck! |
|
24 Apr 2009, 16:00
Shoaib Raza (15 posts) |
Hi Bill, Thanks for your reply. I just wanted to know how can I reload view if low memory warning is coming? For example, I have a MapView (UIView) which loads UIWebView inside. Then I have two ViewControllers 1) List down all saved routes Every things works fine. Now problem is coming when I zoom in to see my travelled route closely and after 3-4 touches, Low Memory warning is coming. I have just two view controllers. What I wanted to do, to make UIWebView=nil and then again loads html page in it. I have polyline point array which I can repass once html page loads successfully. In this way, I can avoid to crash app. Is this way is right way? Also I need to know if I develop the app in SDK 3.0, would I submit app to Apple? Because I have read, app developed in SDK 3.0 can’t be submit. Please clarify!!! Regards, |
|
26 Apr 2009, 11:58
Ronny Bangsund (43 posts) |
Developing in SDK 3.0 at the moment is tricky. It won’t install for me on 2.x, and 3.0 is too unstable for me to dare :) Since there are 30 million 2.x devices out there, that’s the best to develop for. Apple themselves warn against using the beta SDK for releasing apps right now. They are aware of the build problem, and have said the next release will fix that. But right now, use the stable kit and a stable OS to be on the safe side. |
| You must be logged in to comment |

