iAd & AdMob Heavy on Memory - ios

I've just completed coding my new game for the iOS platform and now I decided that it is time to integrate iAd/AdMob banners at the bottom of the screen. I have completed the implementation and an iAd is showing up and if it fails then it is replaced by an AdMob banner. This is great, however I checked over the memory consumption of the app and prior to iAd/AdMob integration, my app was running using around 19MB of memory - with the the iAd/AdMob integration, it is running using over 50MB of memory. I have two questions regarding this - are they supposed to be so memory-heavy like this or am I doing something wrong? Secondly, it seems as if these banner views are never getting released from memory. I have tried setting adBannerView = nil followed by [adBannerView removeFromSuperview] but still nothing happens and the memory does not lessen at all. F.Y.I - my game is ARC enabled.
Any help on this matter would be greatly appreciated! Thanks.

The memory growth you are observing is a result of WebKits contribution to the heap. This unfortunate behavior has been the subject of a lot of outrage. You will find similar behavior if you try and load the banners using your own web views. There has also been similar discussions on SO like this one, and this one where developers have been locked in a futile war to attempt to reduce the memory impact of web loading.
I personally haven't used iAds yet but I am very familiar with Google Ad integration on iOS and we saw significant memory increases post-implementation.
TL;DR
That being said you should consider observing the debug memory gauge, simulate a memory warning, and then your usage should drop. In most scenarios I have encountered WebKit has done a decent job of removing its In-Memory cache.
However, If these memory warnings are not handled you should definitely seek to file a bug report.

Related

What might be the reasons for Performance tool data is high. [ showing in Xcode VM tracker]

I recently profiled my app using Xcode VM tracker instrument.I found that app has lot of dirty memory especially performance tool data. So i want to know what are the reasons of the huge dirty memory and performance tool data.
Any help would be appreciated.
Your app takes 51MB to store, when it is suspended. The performance tool itself adds an overhead of 30MB. Which leaves 20MB for your app.
From the listed items, it looks like your app is graphics heavy. In fact, it looks very similar to this post. Which makes me wonder if these objects are still processing or waiting to be released, when the app is suspended.
Alternatively, I wonder if you could free a lot of those animations and images when entering background, and reconstruct them when entering foreground.
Finally, note that Apple recommends removing strong references to images, data from disk and media to reduce dirty memory.
Since I just had the same problem, here is what I found:
The "Performance tool data" entries were from libBacktraceRecording.dylib.
You can disable backtrace recording in the scheme editor.
See the related question Memory leak with “libBacktraceRecording.dylib” in React Native ios application.

Potential Memory Leak in iOS

So I just made an app that loads a map with some markers on it. The app has a navigation controller that segue from the main screen to the map and back. While running the app on my phone and simulator i noticed that if i went back and forth between the home screen and the map, the amount of memory that the app was using just kept growing indefinitely. Is there way to assist in the process of memory management (i know the system uses ARC)? Im using the google maps sdk btw.
Thanks!
Does it cause the app to run out of memory and crash?
Or is it using a ton of memory, receiving a memory warning, and dumping said memory?
So, unless it is causing crashes, it may be behaving correctly.
Apple has extensive and well-documented support for diagnosing these kinds of problems. See "Locating Memory Issues in Your App".
Check your codes where using NSThreads and GCD blocks. If there are some places you create plenty of threads, it is recommended to add a autoreleasepool block.
Memory may leak in these situation:
If you are writing a program that is not based on a UI framework, such as a command-line tool.
If you write a loop that creates many temporary objects.
If you spawn a secondary thread.
For reference: Using Autorelease Pool Blocks

'Termination due to memory pressure" in UIWebView

I have started receiving app termination due to memory pressures very recently (mostly with iOS 7). The app used to work very well on iOS 6.
The app is mostly uses a UIWebView to display a webpage. However for a few webpages it creates ever increasing Dirty memory with most of it due to Image IO and Performance tool data (see attached instruments screenshots). I am completely clueless as to where to dig next. Could someone guide me what should I do here onwards? In the second screenshot I see a sudden bump in the memory allocations. Is there a way to spot the process/part of the code which caused it?
EDIT One can reproduce these results in a simple demo kept at www.github.com/nikhiljjoshi/iosCrash (just change the site to www.nzz.ch).
Thanks in advance,
Nikhil

UIImagePickerController in source type Camera with allowsEditing to YES causes a “Terminated due to memory pressure” in iOS 7? [duplicate]

I am working on an iOS app in Xcode. Earlier I got it to start and run, up to a limited level of functionality. Then there were compilation failures claiming untouched boilerplate generated code had syntax errors. Copying the source code into a new project gets a different problem.
Right now, I can compile and start running, but it states before even the launch image shows up that the application was closed due to memory pressure. The total visual assets is around 272M, which could be optimized some without hurting graphical richness, and is so far the only area of the program expected to be large. (The assets may or may not be kept in memory; for instance every current loading image is populated and my code never accesses any loading image programmatically.) And it crashes before the loading image has itself loaded.
How can I address this memory issue? I may be able to slim down the way images are handled, but I suspect there is another root cause. Or is this excessive memory consumption?
Thanks,
Review the Performance Tuning section of Apple's iOS Programming documentation. Use Apple's Instruments application to determine how, when, and how much memory your app is using.
One approach you should consider is to disconnect the graphics resources from your application, and add them back one-by-one once you feel they meet the requirements and limitations of iOS.
Now, this part of my answer is opinion: it sounds like your app is a high risk for being rejected from the App Store, in case that is your intended destination for this app.

Core Text occasionally fails to produce results [iOS]

I’m helping out a company with a project for iOS, which is using Core Text. Some users of the app have reported that text is occasionally missing from within the app. It seems™ that this is somewhat memory related, because it’s solvable by shutting down the app along with background apps.
I made a few lines of code which simulates the use of the app – so the app “runs itself”, navigating between view controllers randomly, scrolling in text fields etc – to track if this issue occurs by normal use.
I’ve found some memory leaks related to the use of Core Text, but according to instruments the amount of memory lost is quite low. However, when the simulation has been running for about 20 minutes or so, the app is shut down by the os because of memory warnings.
I’m intending to fix this memory leaks, but my problem is that I will not be able to ensure that this fixes the main bug (missing text), since I cannot reproduce it myself.
So my final question is: have anyone experienced issues with missing text on iOS while using Core Text, which are due to leaked memory? Does it sound plausible? If so, is this related to only specific versions of iOS?
I appreciate any answers that can help me out!
UIViewControllers may implement didReceiveMemoryWarning that the system calls when your app is on low memory. Framework classes, as core text, are most likely do implement this and act accordingly to save memory. So it is possible that your core text object aims to help your app resolving the low-mem situation with freeing some of its resources that can even cause it to blank its contents. Fix first all memory leaks in your app.
On the other hand, all bugs are very difficult to correct if you can't reproduce them. If you suspect that the issue is due to low memory, try to simulate this yourself by allocating huge amount of memory in your application and hope that you can reproduce the erroneous behavior that way.

Resources