Xcode Instrument : Memory Terms Live Bytes and Overall Bytes (Real Memory) confusion
I am working on a Browser application in which I use a UIWebView for opening web pages. I run the Instruments tool with Memory Monitor. I am totally confused by the terms which are used in Instruments and why they’re important. Please explain some of my questions with proper reasons:
Live Bytes is important for checking memory optimization or memory consumption? Why ?
- Creating A TableVIew Programmatically With Objective-C iOS
- How to use a Proxy Server with Alamofire 4 and Swift 3
- Help with multi-threading on iOS?
- CNContact last modified date and contacts changed
- Is it possible to use Mozilla Persona (BrowserID) with mobile apps?
- iphone - how can i get the height and width of uiimage
Why would I care about the Overall Bytes/ Real Memory, if it contains also released objects?
When and why are these terms used (Live Bytes/ Overall Bytes/Real Memory)?
- Xcode 6 Instruments freeze
- Memory leak every time UIScrollView is released
- Can Instruments be used using the command line?
- Memory profiling doesn't work with Xcode 9
- Is there anyway to read performance counters on OS X Mountain Lion?
- Xcode Instruments stops recording when iPad app leaves the splash screen
Solutions Collect From Internet About “Xcode Instrument : Memory Terms Live Bytes and Overall Bytes (Real Memory) confusion”
“Live Bytes” means “memory which has been allocated, but not yet deallocated.” It’s important because it’s the most easily graspable measure of “how much memory your app is using.”
“Overall Bytes” means “all memory which has ever been allocated including memory that has been deallocated.” This is less useful, but gives you some idea of “heap churn.” Churn leads to fragmentation, and heap fragmentation can be a problem (albeit a pretty obscure one these days.)
“Real Memory” is an attempt to distinguish how much physical RAM is in use (as opposed to how many bytes of address space are valid). This is different from “Live Bytes” because “Live Bytes” could include ranges of memory that correspond to memory-mapped files (or shared memory, or window backing stores, or whatever) that are not currently paged into physical RAM. Even if you don’t use memory-mapped files or other exotic VM allocation methods, the system frameworks do, and you use them, so this distinction will always have some importance to every process.
EDIT: Since you’re clearly concerned about memory use incurred by using UIWebView, let me see if I can shed some light on that:
I don’t have any knowledge of UIKit or WebKit internals, but I would expect that if you had a discussion with someone who did, their response to the question of “Why is my use of UIWebView causing so much memory use?” would be two pronged: The first prong would be “this is the price of admission for using UIWebView — it’s basically like running a whole web browser in your process.” The second prong would be “system framework caches are automatically managed by the system” by which they would mean that, for instance, the CFURL caches (which is one of the things that using UIWebView causes to be created) are managed by the system, so if a memory warning came in, the system frameworks would be responsible for evicting things from those caches to reduce the memory consumed by them; you have no control over those, and you just have to trust that the system frameworks will do what needs to be done. (That doesn’t help you in the case where whatever the system cache managers do isn’t aggressive enough for you, but you’re not going to get any more control over them, so you need to attack the issue from another angle, either way.) If you’re wondering why the memory use doesn’t go down once you deallocate your UIWebView, this is your answer. There’s a bunch of stuff it’s doing behind the scenes, that you can’t control.
The expectation that allocating, using, and then deallocating a UIWebView is a net-zero operation ignores some non-trivial, inherent and unavoidable side-effects. The existence of such side-effects is not (in and of itself) indicative of a bug in UIWebView. There are side effects like this all over the place. If you were to create a trivial application that did nothing but launch and then terminate after one spin of the run loop, and you set a breakpoint on
exit(), and looked at the memory that had been allocated and never freed, there would be thousands of allocations. This is a very common pattern used throughout the system frameworks and in virtually every application.
What does this mean for you? It means that you effectively have two choices: Use UIWebView and pay the “price of admission” in memory consumption, or don’t use UIWebView.
- A Lot of Functions are deprecated – iOs 6
- Programmatically remove contact from adress book on specific time in swift
- Trying to get network error alert to show on iPhone app?
- iOS: How to get owners email address?
- Get to UIViewController from UIView?
- In UINavigationController what is the difference between topViewController, visibleViewController, presentedViewController?
- Simple way to read local file using Swift?
- Access BPM field on a song (MPMediaItemPropertyBeatsPerMinute not working)
- Storing video for offline use in PhoneGap/Chrome Apps
- Can we find historical data usage(Wifi / Mobile Data) of the installed application through libimobiledevice or iOS APIs?
- UIStatusBarStyle not working in Swift
- UIScrollView child jumping after UINavigationController push and pop
- Is there any way to get the neat Objective-C literal indexing feature in Xcode 4.4?
- Import LocalAuthentification.framework crashes on iOS 7.1
- tableView.tableHeaderView being set but not drawn