Hi I am basically loading a webpage within my app and every time I open the webpage
my app crashes after it receives 2 memory warnings(didreceivememorywarning) of level 1 and last on is randomly level 1
and level 2 and finally app receive signal 0 and app crashes on the spot. can't we load just a single webpage
You're running out of memory. Either your web page (and included images and such) is too huge, or your page contains javascript that is allocating too much memory, or something else in your app is using too much memory and the web page is just the straw that is breaking the camel's back.
Related
I have one user (with an iPhone 5) reporting that my app crashes on launch about 15 seconds after the screen goes black (the splash screen is black). The user downloaded a TestFlight build where I included checkpoints in the App delegate, but I don't get evidence that those checkpoints are crossed, and I never get a crash report.
I changed the entry point on the storyboard to a blank view controller, and now I can see that the checkpoints are being crossed. It's occurred to me that Watchdog is suspending the app due to storyboard resources taking too long to load, but all the images are built in real-time as needed, with the exception of four tiny tab-bar icons. There are several audio files but they are loaded on demand. I can't think of any other resources that could be causing a delay. No one else has reported this problem, and I'm stumped.
Any insight appreciated, especially as to why I'm not seeing a crash report or checkpoints from TestFlight.
Your assumption is correct, the watchdog killed the app. This is because the app doesn't start up properly and either the main thread is blocked or no user interaction is possible since no UI is loaded.
As I understand your description, you are creating the resources while loading? And probably doing this on the main thread? You should try to offload resource hungry code into a background thread instead of doing this on the main thread where older/slower devices could take much longer than expected. The UI should always be responsive, the main thread should never ever to tasks that could get anywhere close to one second of processing.
Another reason could be that the link between the storyboard and the view controller is broken and it actually never loads on that device type.
But without more details it is impossible to say what exactly is going on.
In general: If the app is killed by the iOS system, e.g. by the watchdog due to startup time exceeding or due to allocating too much memory, then only iOS can generate a crash report.
The problem is that the app gets killed and in that case the process is killed. And that cannot be detected by any code running inside that process. And since crash reports on iOS, other than the iOS system based crash reporter, do run inside the same app process that is being killed, they cannot report or write any crash report.
The following page gives some more details on this: http://support.hockeyapp.net/kb/how-tos-faq/which-types-of-crashes-can-be-collected-on-ios-and-os-x (Though with context to PLCrashReporter, which is not used by Testflight. But the general statements are identical)
I am developing an Application for iPad & it consumes 5.5 MB at max on RAM of the iPad. I have ensured all this stuff using Instruments number of times. As soon as App uses little bit more memory, It throws memory warnings & app start behaving abnormally.
I have implemented the lines of code for freeing the memory in did-receive memory warning.
I also have ensured that NO LEAKS in the entire app.
I came to know that App needs at-least 6 mb memory.
Here is the general flow of the app.
log in -> 1st-list View -> 2nd-list view -> 3rd-list view -> 4th-Map & listview -> 5.Map&List
brief of each screen.
log-in - simple screen with username-pswd, making a web-service call & authenticating user
based on result of authentication, it will fetch few more data & list it on 1st-list View screen.
based on selection from 1st-list, app will load list on 2nd-list view
based on selection from 2nd-list, app will load list on 3rd-list view
based on selection from 3rd-list, app will load list & map will have pins relatively.
based on annotation from Map, app will navigate to another maps & different pins.
Here, app receives memory warnings on 6th screen. I have ensured all coding standards & all importance of all objects.
In Above case, All screens are very necessary, I am using Navigation Controller & just pushing view-controllers one by one. no duplications - ensured twice.
Now, the point is, App is being tested on iPad-1 with iOS 4.1 & all apps are forcefully closed before starting the testing of the app.
THOUGH, app receives warnings # just 5.5 mb usage.
I tried to convince my project managers that, this amount of memory usage is high & they are asking me - there should some option to set MEMORY. How this kind of High Graphics games & apps are running smoothly ?
I can't find appropriate document from Apple saying LIMIT. I have no answer to them.
If setting Memory limit is not possible, I am requesting you to provide Appropriate PROOF link, so that I can show it to my Project Manager.
If that kind of settings is possible, I am highly eager to know how to make that.
I doubt you will find any positive statement about memory limits for an app under iOS coming from Apple docs.
But if you google "ios app available memory" you will find a lot of information; e.g., this S.O. thread.
In my experience, my apps can sustain a "peak" memory usage of about 20MB (depending on the device state), but then memory use must quickly go well below the 10MB threshold for the app not to be killed (I would say that 6-8MB is more precise figure). Sometimes an app can be killed just because a peak cannot be "undone" fast enough.
One piece of information that might be useful for your managers is the output from the "Memory Monitor" tool in Instruments, specifically the "free physical memory". If you use it, you will invariably see that your app will be killed when the "free physical memory" goes below a given limit (as per Instruments output), approaching zero left memory.
Now, whether that limit is reached because you allocated some memory (which is reported by the Allocations or Leaks tools) or because of other factors (a framework loaded into memory? something in the iOS kernel or that is not tracked by Instruments?) you cannot know. But for sure you can follow how the free physical memory in the device varies over time with the use of your app.
Hope this helps.
The first generation iPad has a total of 256 MB of memory. Of course some of that will be used by the operating system itself.
It's very conservative to assume that at least 64 MB would be available for your application. So 6 MB sounds pretty minimal to me. There must be something your application is doing that causes more memory to be allocated.
There definitely isn't some "I'm a game let me use more memory option". All applications are allowed to use as much memory as they can (though it's always a good practice to minimize memory usage). If memory runs low, the application is notified, and if memory is exhausted, the foreground application is terminated.
If your application is terminated, examine the crash log to see how much memory it was using. My guess is that you'll find you are using more than you think.
in my app i have a UIWebView and in that web view i am loading some text and images. I am getting those datas by parsing from an rss feed. When large datas get loaded my app get crashed saying that memory warning. How to avoid this memory warning issues in my app
Sorry, but there's only one real answer to this: use less memory.
When you get the memory warning you should clear out any caches or temporary data that can be recalculated. As you've found, if you don't do that iOS will kill your app.
I'm trying to find ways to reduce load times for a large application.
Here is some background:
The app uses a lot of the iphone frameworks (openGL,mapping,location,quartz,audio) as well a few libraries from other sources (JSON, ARKit, Flurry, Facebook connect)
The code + nib size is around 3.5MB with about 150 source files.
The app compresses to around 2.5MB.
Load times are around 13s on an iPhone 3GS. The actual time spent in my code is only around 1s. (from the start of main() to the end of applicationDidFinishLaunching)
The app delegate has references to most of the view controllers in the app as they are referenced from many places and often store persistent information.
Everything in the app is already lazily initialised so I can't just do things later on.
Is there anything I can do to reduce the load times in this case or is this just how long the device takes to load all the code into memory? I don't know very much about how compilers/linkers work so I was wondering if there are any coding practices that can reduce load times?
13 seconds is incredible. Linking to a few libraries should not take that much time.
Note that running it while attached to the debugger will make launching slower, because GDB spends a while looking up symbols or something like that.
I am writing an application that uses UIImagePickerController to take multiple pictures with the camera as fast as iOS allows. My application has to run on iOS 3.13 on all versions of iPhone hardware (v1 through 4). I am using UIImagePickerController with a cameraOverlayView.
My question is, how can I determine programmatically how many photos can be processed at once based on available memory? See below for more details. Any help is appreciated!
When the imagePicker delegate recieves imagePicker:didFinishPickingMediaWithInfo:, the delegate saves the full size image in the savedPhotosAlbum with UIImageWriteToSavedPhotosAlbum(). Once I have this problem solved, the app will be doing more things with the full size image.
As a test, I take pictures as fast as I can. Eventually, as expected, the app receives memory warning due to the large number of photos in memory while saving to the photo album. If I ignore the memory warnings and continue taking pictures, eventually the app is killed by iOS b/c of this.
I have no problem with setting a limit on the number of concurrent photos I allow the app to process at a time. Each iPhone HW version has different memory capacities and different camera resolutions. With iOS 4, multi-tasking may also effect the available memory. I'd rather do this programmatically than hard-code a limit based on HW version.
A test application that shows this behavior is at Source Code
It's easier to hard-code the limit.
There's no easy way to find out what the "available memory" is, since more memory may suddenly become free if there's a memory warning, or if the phone decides to kill various background apps (namely Safari). There's NSRealMemoryAvailable(), but that might just return the installed RAM (and is probably what [NSProcessInfo physicalMemory] uses).
You could try saving images in a queue — saving one image at a time is likely to use less memory. You can also add markers to your queue when you receive a memory warning, and disable image-saving when there's more than one (ideally you want to stop taking pictures if you get "level 2" or "level 3" memory warnings, but while these are printed to the console, I don't know any easy way of checking in code. Presumably you want to resume on a memory un-warning, but these don't exist either).
Also note that you can get the raw JPEG data (on some OS versions) through a notification; I forget what the name is, but the userInfo key is #"AVCaptureNotificationInfo_JPEGData". If you save the raw JPEG data, you might be able to process it later.
I think UIImageWriteToSavedPhotosAlbum() stupidly decompresses the JPEG returned by the camera and recompresses it, but I could be wrong. Camera images are only around 1-2 MB, so you ought to be able to take plenty without it crashing, but in my tests that's not the case.