New empty iOS app has dozens of memory leaks - ios

Using the Leaks Instruments tool on a new, from-scratch, one-view iOS app reports 23 leaks. This doesn't seem right — am I missing something? Repeated runs yield different leak counts, from 16 to 35. Steps to reproduce follow this screenshot.
A similar, unanswered question, was posted at Memory leak in login with amazon sample ios app
I'm using Xcode 10.2.1 (10E1001); iOS 12.2 (Simulator & device both show leaks, with or without Reveal activated.)
Create fresh one-view iOS app.
In Scheme > Run/Debug section, enable
Memory Management > Malloc Scribble
Logging > Malloc Stack (Live Allocations Only)
Run Product > Profile (⌘I)
First leak check is green; wait for second one.
Twenty-three new leaks! (As shown above.)
However, apart from Instruments, Debug Navigator disagrees:
Run normal debug session
Click "Debug Memory Graph" at top of Debug area.
Debug Navigator (below) has no purple exclamation marks (leak alerts).

The release notes for Xcode 10.3 say:
Resolved an issue where running an app in iOS 12.2 or later under the Leaks instrument resulted in random numbers of false-positive leaks for every leak check after the first one in a given run
That sounds exactly like this issue. So it was a bug (a Heisenbug?), and now it’s fixed.

Related

How to find the place where the iOS code crashes using Firebase ? (when you can't reproduce the bug)

I'm using Firebase to get information about crashes of users of my application. Most of the crashes has no any useful information about code or place where it happens. All stack-trace and threads shows "Missing" text. Also I can't reproduce these crashes at my PC.
That crash is on Mac OS application, not iOS. My point of view is to look at that doc, (see "Build Your App With Symbol Information"). But may be on Mac OS apps that feature is not available.
https://developer.apple.com/documentation/xcode/building_your_app_to_include_debugging_information
What can I do to find the place it crashes ? See attached screenshot

Parse iOS framework causing memory crashes

I've used Xcode's zombie debugger and managed to find this flag upon launch:
This crashed the app, and re-recording from Instruments caused the same result. Relaunching the app from the device made the app launch without a crash and subsequent launches from Instruments resulted in normal operation without flags or crashes.
Can anyone make sense of this or advise? I'm getting a number of "heap corruption" crashes in production. The reports are limited to a handful of users, but I'm afraid that number is growing.
It looks like the Parse SDK's latest release notes (1.15.1) addresses this:
-Adds polygonal queries
-Fixes memory leaks related with PFCommandCache
But my crash reports are coming from builds with this SDK version.
The Parse team has responded saying that a fix for this is coming to a new SDK release soon. :)

Looking for local crashlog when device was tethered to Xcode

Question:
When iOS device is tethered to Xcode and crashed after building (app loaded in, was not a crash ON build), where is the crash log saved to?
Here's my predicament with some context:
I pulled a user's crashlog of EXC_BAD_ACCESS for my app. I symbolicated and I've narrowed it down to get a rough idea but now I'm trying to re-create the issue via building in Xcode to my iOS device (not simulator). Normally the app does not crash on load in (this crash isn't easy to replicate) but I've been able to have the app crash consistently with Address Sanitizer enabled, and it always crashed and points to a line in a thread with an men address -- not anything I don't already have from previous debugging.
However, one time I had a crash occur where it highlighted what func was called as well as every func called in the stack trace and what file this was all occurring in. In haste I hit build again in Xcode before I saved the output however... and now I cannot replicate.
The crashlog wasn't saved locally to my iOS device as I was still tethered to Xcode, and I checked ~Library/Logs/CrashReporter/MobileDevice but that did not contain them either.
I need find where Xcode would've saved these logs on my mac (if it did at all)?
Typically all the crash dumps are stored in Settings -> Privacy -> Diagnostics & Usage -> Diagnostics & Usage Data
Scroll down the list and find the crash file with your app name.
This link might be helpful - https://developer.apple.com/library/content/qa/qa1747/_index.html

iOS App crashes / Xcode shows no backtrace (Paused)

I'm trying to debug a crash (likely memory related) but whenever the app crashes while debugging on iPad device Xcode (4.2) shows Paused with no backtrace for any thread (GDB). Switching to LLDB provides even less -- the app crashes, console shows nothing and Xcode ends debugging.
The crash only occurs after intense use and is likely related to insufficient memory.
I can't find any info related to the crash though. Anyone else experienced this behavior?
Have you set the exception breakpoint?
got to breakpoint editor pane
click on the [+] in the bottom left corner of the pane
choose add exception breakpoint
Now you should see a stacktrace if an exception occurs.
"Appearing after intensive use" indicates to excessive memory usage and memory leaks, and not that not enough memory is available.
Run the application on your device with instruments running and turn on the leaks module to find where you are not freeing allocated memory.

How do you enable NSZombie in Instruments of Xcode 4.1 under Lion?

This is ONLY regarding the new Xcode 4.1, specifically running on Lion. How do you enable NSZombie in Instruments ? It is no longer in Allocations in the (i) icon under Launch Configuration as in Xcode 4.0. Nor is there a Library entry called Zombies.
Of course the problem is I cannot fall back to Xcode 4.0 because it refuses to run under Lion, so I'm in a pickle ! Any other bleeding edge developers using Lion who, with more experience than myself, can help dig this out ? Thanks. -Ric
I got this very useful answer from Apple regarding my own question. It is verbatim -
ME: Is there an update as to how to find those tough deallocated objects, testing on the device, using Xcode 4.1.1 and/or Instruments ?
APPLE: First up, the hack shown above [in Apple's Forum] has been obsoleted by internal changes to the OS, namely, Zombie setup is now done by CF. You can force zombies enabled using the code shown below:
extern void _CFEnableZombies(void);
int main(int argc, char **argv)
{
_CFEnableZombies();
... rest of your main ...
}
IMPORTANT: The _CFEnableZombies function is private, so you don't even think about putting this code into a production app. However, it's not secret; you can see how it's implemented by looking in the Darwin open source for Lion.
http://www.opensource.apple.com/source/CF/CF-635/CFRuntime.c
If you do this, your app will stop (with a breakpoint exception) when you message a zombie, regardless of how you run it. So you can run it in Instruments with the Allocations instrument and get both zombie detection and allocation tracking.
Note that when a zombie is messaged the system prints something like this:
*** -[ ]: message sent to deallocated instance "
This doesn't appear in the Instruments console area; you'll have to use the Xcode Organizer (or iPCU) to view it.
Share and Enjoy
Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
ME: hope that is useful info for some of you in this situation.
It's a distinct instrument:
There is another way to run with NSZombie on the device, but this is done through XCode 4 not instruments.
To run with NSZombie on the device open your XCode Project and click on the top menu item "Product" then hold down alt and click "Run" this will open a separate window where you will see "Environment Variables" in the bottom of the window. Hit the "+" and enter "NSZombieEnabled" for the name and "YES" for the value.

Resources