views:

784

answers:

2

I recently had an app rejected from the app store because of Low Memory Exception. The app doesn't leak memory, but its base memory footprint seems to be too high. According to the crash logs sent by apple, it was taking about 14000 pages in the memory (mostly due to huge textures). There were 2 strange things though:

  1. I tested it on 5 devices rigorously before submitting, and never got this crash on any one of them.
  2. I did optimize the textures after the rejection, and brought them to about half the original size (texture memory consumption).

I have no way of knowing how many pages my app is taking now, unless I can reproduce the same crash as apple (which I never could). Is there another way to be able to find out the memory footprint of my app, so that I can be sure that it is optimized enough now.

I did try instruments, but my app crashes when I try to run it through my XCode (must be some problem with my XCode). But it works perfectly when I run it directly on my iPhones/iPods. Any help in finding out the memory footprint of my app on iPhone (if there is something analogous to task manager of windows), would be appreciated.

Thanks

EDIT:

  1. Launching the app from XCode gives the following error in the console: "Error launching remote program: failed to get the task for process 553."

  2. Launching the app with Activity Monitor gives the following error: "Target terminated too early to collect data"

EDIT2:

I was able to run my app with Activity Monitor, by using a dev profile instead of distribution profile. But now there are several sections in the Activity Monitor - Physical Memory Used, Real Memory, Virtual Memory. Which one of these do I consider. To sum it up, I need to know which one of these causes the iPhone to throw a Low Memory exception.

+2  A: 

XCode -> Run -> Run With Performance Tool -> Activity Monitor.

If the device is connected, Activity Monitor runs on the iPhone/iTouch.

diciu
"I did try instruments, but my app crashes when I try to run it through my XCode (must be some problem with my XCode)." - Activity Monitor is an instrument.
Prashant
You are not running the application through Xcode when you do this. Start the application manually, then bring up Instruments and connect to your device. My recommendation would be to use the Memory Monitor application, as it should give you an accurate breakdown of your application's memory usage, along with the total system memory usage.
Brad Larson
+2  A: 

I think you're coming at this from the wrong angle. You're asking how to find the memory footprint without using XCode. I think the question you should be asking is: why can you not use XCode? Presumably that's what you used to develop the application in the first place?

Without XCode you're pretty much flying blind. You say you halved the size of your textures, but how do you know? Does your app release any extraneous memory when it gets a low memory warning? (applicationDidReceiveMemoryWarning:)

First, have you looked at the crash logs from when you run your app from XCode? You should be able to see them in the Organiser in XCode.

I'm not sure there's a single solution to stop your app crashing with XCode. Normally when my iPhone won't allow debugging I just restart and my handset and it starts working again. Restarting XCode sometimes helps. I would also try reinstalling both XCode and the iPhone SDK.

Stephen Darlington
It turned out that you were right. I was trying to run the distributable version of my app using XCode. Ideally that should be no problem, but it seems that there is some hidden issue with XCode while running the dist version. So I changed to Debug and removed the code signing entitlements from the project. This enabled me to run the Performance monitoring tools using Instruments.I also tried to reinstall the iPhone SDK and XCode but that didn't make a difference.
Prashant