I'm using Allocations to profile my app to see if it has any memory issues. Every time I click "Mark Generation" I get a new memory snapshot and I can see how much memory increases during two generations. However, the growth value always decreases for a few seconds until it stops, and I'm quite confused about this. Sometimes the initial growth can be more than 20MB, but finally drops to around a few hundred KB. Why is this and which value should I trust?
Why does the memory growth keep decreasing after I click "Mark Generation" in Xcode Allocations?
188 Views Asked by P. Tsin At
1
There are 1 best solutions below
Related Questions in IOS
- URLSession requesting JSON array from server not working
- Incorrect display of LinearGradientBrush in IOS
- Module not found when building flutter app for IOS
- How to share metadata of an audio url file to a WhatsApp conversation with friends
- Occasional crash at NSURLSessionDataTask dataTaskWithRequest:completionHandler:
- Expo Deep linking on iOS is not working (because of Google sign-in?)
- On iOS, the keyboard does not offer a 6-character SMS code
- Hi, there is an error happened when I build my flutter app, after I'm installing firebase packages occurs that error
- The copy/paste functionalities don't work only on iOS in the Flutter app
- Hide LiveActivityIntent Button from Shortcuts App
- While Running Github Actions Pipeline: No Signing Certificate "iOS Development" found: No "iOS Development" signing certificate matching team ID
- Actionable notification api call not working in background
- Accessibility : Full keyboard access with scroll view in swiftui
- There is a problem with the request entity - You are not allowed to create 'iOS' profile with App ID 'XXXX'
- I am getting "binding has not yet been initialized" error when trying to connect firebase with flutter
Related Questions in XCODE
- I am getting lots of errors when building react native app in Xcode
- Xcode commits (possibly outside of any branch) disappeared, how to get them back?
- Can't run built SFML project from Xcode template
- Postal Framework crash in iPhone but runs successfully in simulator
- React Native - RealmJS - Linker command failed with exit code 1
- how to install xcode on macos hight sierra without apple account
- Xcode: Can't Attach to process
- Issue with Xcode Target and settings for Apple Watch App
- There are no active runners online GitLab
- My project code not running in Xcode(15.3) but the same code running in Xcode 14.2 in swift how to fix in xcode 15.3?
- How to press and hold in Xcode simulator
- Memory management for image data storing and retrieving with SwiftData (or CoreData)
- Error: spawn flutter ENOENT in flutter build_runner
- Can a project using Crashlytics have a GoogleService-Info.plist file renamed to something else?
- What changed from xcode 13.2.1 to 14.2 that would affect an app's entitlements?
Related Questions in INSTRUMENTS
- How to programatically get the UI Hierarchy in my automation script?
- From where does target.logElementTree() retrieve information?
- Memory Leak using an UIAlertController in Swift
- How to tap a button in UI Automation which has only coordinates?
- How to get back to the application which escapes control?
- Memory leak in String Formatter
- Read a Xcode Instruments .trace file generated from Automation.tracetemplate
- Xcode 6.3.2: Instruments keep asking for trace template?
- What is the number percentage after code line means using Instrument?
- Is there a way to measure the memory usage of other iOS applications?
- instruments[34247:1345307] Attempting to set event horizon when core is not engaged, request ignored
- UIAutomation - command line issue
- Instruments memory leaks detecting issue in Xcode 6.2
- Does Xcode instrument works on real Apple Watch device?
- Is there an easy way to measure the FPS of my Mac app?
Related Questions in XCODE-INSTRUMENTS
- SwiftData leaks
- Why is my app crashing on an iPad due to low memory?
- Memory leaks detection in Intruments did not work
- Xcode Instruments “Points of Interest” dropping intervals
- Error while tying to run instruments with Xcode 15
- Is latest Instruments not support A17 Pro for CPU counters?
- Xcode Instruments launches wrong build
- Accessing some of AVAudioEngine properties or methods causing a memory leak in Xcode Instruments
- Xcode Instruments- Trace file creation programmatically in XCUITest
- How to See Line Numbers in Instruments Performance Profiles
- Points of interest not showing in Xcode Instruments
- Understand the output of XCode Instruments
- Is latest Instruments not support A16 for CPU counters?
- Is there anyway to check how long microtasks take to execute?
- Unable to profile simple C++ program in Instruments: "failed to execute loader thread"
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?



I would suggest that you simply do not focus on “generations” list, and its “growth” column, at all. It has a lot of noise in it (e.g. a ton of stuff that is going on the background) and does not capture some salient information.
Consider the following. I profiled an app that repeatedly allocates and deallocates a huge 70mb array. I marked generation A, then allocated the 70mb array, marked generation B, released the array, marked generation C, allocated the huge array again, marked generation D, released again, and then marked generation E:
The allocations graph accurately illustrates what I was doing in the app, but the “generations” list does not. It is telling me that generation D saw a growth of 26.95kb, even though actual memory usage went up by 70mb!
What is generally far more useful is the “Allocations” graph. Here I will select the interval from generation C to generation D:
When switched to the allocations list, and sorted in descending order of size, I now see my large array allocation. I even see a stack trace of where the allocation happened in
Foo.init. And that is indeed where the allocation is taking place:I confess that most allocations problems are not this easy to find. I manifested an easily discovered issue by doing a single huge allocation. Because reverse engineering the allocations can be so difficult, unless I am dealing with unsafe pointers and manually allocated buffers, my first line of investigation is generally Xcode’s “debug memory graph” (see https://stackoverflow.com/a/30993476/1271826).
I might also advise watching WWDC 2021 video Detect and diagnose memory issues and see the various other links on that page. It describes a lot of very advanced techniques.
Regarding the changing of previous generations’ “growth” values, it safe to say that to the extent that “growth” has value at all, one can safely assume that the final value is more reliable. Real-time instruments logging (as opposed to “deferred” logging) frequently updates previous graphs and values as Instruments catches up with all of the logged events.