Why does my app always open with a memory warning, if there is almost no code for the first view? - objective-c

I recently have been getting memory warning messages when I load my app on my iPhone. I believe it has something to do with the storyboard that I recently switched over to from the classic .xib files. The app has been running a lot slower since and I don't get why. I got rid of a ton of my code that I was using for loading views, making tables, etc., so I would think that my app would run a lot faster now than it did before. My mainViewController (which is giving me the most problems), only has the default code in it! Is there a reason for this to be happening? Was the code running faster than storyboard or something?
Thanks in advanced.

Profile using Instruments to understand your app's execution -- CPU time (slow) and Allocations (memory consumption).

Related

Is it possible to relauches an ipad application?

I have an application used mainly with uiwebview since we have a lot of work based on the website so it is quicker to show it directly on webview without re-coding it. The problem with webview, it is very expensive on memory. The UI is running fine throughout 10 times of going through from beginning of the application to the end of the application and repeating the process. On the other hand, the webview started to get slow when it doing some javascript animation using Canvas object. I have put in some code to remove NSUrlCache when it received warning.
Our application is based on navigating through stacked pages. When it gets to the end, user basically goes back to beginning. In my mind, I wanted to relaunch the application when I knows the application started to run slow. I know it is not a good idea to do this but I don't know what is the best way of reclaim the memory. I have looked through all of my code and have released what i have to released. The Application is going well without problem but it is just the uiwebview caused the performance.
Please Help...
Short answer: Not possible. You'll have to find a different way to address your performance problems.
If UIWebView is bottlenecking your application then the solution would be to NOT use UIWebView. You cannot simply "restart" or "reset" your application. If performance is decreasing over time as your app is being used then this suggests that you might not be managing your memory or object allocations properly. You can use the Leaks instrument to debug your application and try to hunt down memory leaks and you can use the Allocations instrument to analyze your object allocations.

Crash with no info

Well, while running my iPhone game on my iPhone 4 through Xcode, my app crashed (sometimes does, sometimes doesn't), and when it crashed, Xcode didn't throw me any info. In the log, I could see (gdb) written, but nothing else that could help me find the problem.
What could cause such an error? At least it should tell me something, no?
Crashes without explanation on the device itself are often due to using up too much memory; the device simply terminates the app when it has requested more memory than available. This is easy to do in game development, with all those images.
Use Instruments to track memory usage, and/or put some good memory management code in the App Delegate methods for memory warnings and always release as much as you can.

Help diagnosing crash in Cocoa framework - possible memory leak?

I'm currently migrating the Fragaria framework from a GC-only environment to GC being supported. After the work was done (or what I thought had to be done to make it work) I was able to run the examples that come with the framework without any problems and Instruments didn't show any major memory leaks.
I included non-GC Fragaria in my non-GC application and it crashes as soon as I place the cursor on it. To be honest the usage pattern is different from the examples as I'm embedding it in an instance of NSViewController instead of NSDocument.
Can you give me some tips on how to debug this? I'm a bit lost on where to proceed now.
First thing to do is Build and Analyze the code, then fix any problems it finds.
Next, try running with Zombie detection enabled (google NSZombie).
Finally, each crash's stacktrace should give you a pretty good idea where things have gone off the rails.

iPhone Simulator is slow compared to device

I've been working on a new app, and when I run it on the simulator, it's VERY slow. There's nothing fancy in the app, just UINavigationControllers and text. The slowness only occurs if I launch the app from Xcode (with or without debugging on, doesn't matter). If I run the app on my iPhone or launch it directly from the simulator by clicking it's icon from SpringBoard, the performance problems all disappear.
For what it's worth, all my other apps perform just fine when run launched from Xcode in the simulator, so it must be something specific to this app. Has anyone experienced this before?
UPDATE: There is no performance hit when the app is run through Instruments either. I'm not using any 3rd party libraries. It's all calls to the Apple SDK.
Thanks,
Arash
Have you looked at it in Instruments to see where it's spending its time? No reason to guess when you can test.
Running an app in the simulator while in active debugging will always make the app slower. Always, and in a way that is exactly what you are describing.
Basically, "Build and Go" will be slow because its running the debugger.
This is different from "Debug" vs. "Release". The debug build will run fast if you aren't actually debugging it.
Are you using NSLog() to print a large amount of information? When you launch through Xcode, that information is piped to the debugging console and, if there's a lot, will take time to update the window. When you launch directly or on the device, the data is simply stored in a file, which generates less overhead.
I once reduced a program's run time from several minutes to a few seconds simply by removing logging statements. Unfortunately, it was for a timed programming contest.
I had the exact same problem and spent about 2hrs now to solve it. In my case I think it was because I had "Enable Guard Malloc" set. If it wasn't that, my other guess is bad karma.
Simulator Debug, You should need to be ensure when your app running on simulator debug->slow animations isn't check marked

What can cause a UIView to be arbitrarily removed from the hierarchy?

I have an iPhone app that, for some users, sometimes behaves as if with the main UIView has been removed from the view hierarchy. It always happens coincident with a significant event in the game. Other Core Graphics-drawn UIViews that are above it in the z-order remain, but the main one (an OpenGL view) appears to be gone, leaving the background (a solid color).
The app does not crash (it keeps running, without the view), and this seems to happen very consistently for affected users. Unfortunately I am not able to reproduce it.
I suspect a memory issue -- that would be the easiest explanation -- but based on my reading it looks like didReceiveMemoryWarning only deallocs views that aren't visible, and aside from that the memory usage for my app is pretty small. Also, the "significant event" only results in OpenGL drawing and a SoundEngine call -- no view manipulation.
Anybody out there seen something like this before?
Yes, infact one of my applications very occasionally exhibits this problem and it does seem to be memory related.
I have had no success tracking it down either by debugging or analyzing the program flow. I have verified that the view in question is destroyed and not just hidden in some way.
It happens so infrequently that I haven't looked into it to deeply, but I do think it's caused by something in the OS in some way,
You can easily test low memory in the simulator to debug this problem if it is memory related.
The problem ended up being an uncaught NSException (from a third party library) thrown in the app's timer thread, which killed the timer thread but not the rest of the app. The good news is that crash reports are generated in this case, which can make tracking it down much easier if you know to look/ask for them.
As is made clear in the SDK documentation, when your app is running low on memory, views that are not in use can be collected. When it's needed again, it's re-created. This is to conserve precious iPhone resources. Your best bet is to retain the view so it can't be released.