IOS7 - Xcode5 - Memory Leaks with NO CODE - ios

first of all, sorry for my english. Now, i've made a simple app in Xcode 5, with a TabBar Controller and a Navigation Bar Controller embed in it. When i run the app with profile i see some leaks (32bytes) that appear when the app goes in background mode. This happen only when i use to embed Navigation Controller in Tab Bar Controller, even if i don't write any single line of code. in stack trace the only function for the leaks is in main.m.
How is it possible?
The type of leak is:
Leaked Object # Address Size Responsible Library Responsible Frame
__NSCFString 1 0x17530290 32 Bytes Foundation -[NSPlaceholderString initWithFormat:locale:arguments:]

Memory leaks dont just happen, Xcode is a derp. Turn it off and on again and it will work like a charm.

Related

Memory leak in WkWebView instantiation

I have a Viewcontroller which contains wkwebview when I pop it from the navigation controller I get memory leak
The stack trace leads WkWebview instantiation
I am not using any delegates as well.
I am really wondering what causes this and how to fix this
It is not observed for a long time (at least I can't remember when I met it last time). Just tested in Xcode 11.2 / iOS 13.2. No leaks - neither in simple test project nor in Playground.
Thus, I assume it should be analysed real usage, which introduces leak.

iOS7 UIToolbar crash

I have an iPad app that has been running fine until iOS7. This issue seems to be only on ipad 2nd gen models and earlier when iOS7 is installed. Anyway, I've been tearing my hair out trying to figure out where this error is coming from, but have had no luck. The console in xcode (5) reports the following error after I perform a logged in segue:
2013-11-18 11:17:31.768 MyApp[400:60b] *** -[UIToolbar backdropView:willChangeToGraphicsQuality:]: message sent to deallocated instance 0x18ec23e0
I can't lookup the address for more info (image lookup -a 0x18ec23e0) it just returns nothing.
In instruments running zombies, it reports that a message was sent to a UIToolbar like so:
When I inspect the instance, I get the following:
How do I debug this? I have no idea where this call is being made and it seems dependent upon a physical deivce (doesn't happen on the iPad mini or ipad 3/4)
I was struggling with a very similar error, also with a UIToolbar, that I couldn’t figure out until a couple hours ago. I also had to use and try to understand the zombies’ instrument but without any luck.
What I did was to pay a close attention to the call stack that was presented when the Exception Breakpoint was activated as described in the following tutorial:
http://www.raywenderlich.com/10209/my-app-crashed-now-what-part-1
Even though the call stack didn’t point me to the exact code line, I noticed that the app was trying to add a UIToolbar to a ViewController. Turns out that what I was doing was creating a local UIToolbar inside of a method and adding it to the presented UIView. After have modified this behavior, I stopped having the annoying sudden crash. It was difficult for me to find the issue because looking at the code of the ViewController that caused the crash, there was no code that created or used a UIToolbar; however this VC included a custom view that did exactly that, as I explained before.
Have said all of this I recommend you to closely inspect the VC that generates the crash. If you need to create a UIToolbar programmatically I recommend you to declare it as a strong property to maintain the memory reference as long as needed.
I hope this helps you.
I struggled with this for a while today. I had two storyboards, one for login/signup (set as the main storyboard for the project) and another with the rest of the application. The app delegate would detect if a user was logged in and instantiate the root view controller of the other storyboard. The root view controller of the login storyboard is a navigation controller and after after some investigation with instruments I realized there was a UIToolbar being instantiated from the nib. Opening up the storyboard file revealed an off-screen UIToolbar object in the root view controller. I deleted it and I'm not crashing any more.
I should also mention this crash was only occurring when I was using MKMapView.

ios puzzle app crashes after a few rounds

I have an iPhone app, that seems to have memory leaking problem. It's a puzzle game, after a few puzzles, the app crashes on devices.
I'm now trying to use xcode Instruments to detect what's going on. First time to use Instruments.
I noticed a leak bar in the "Leaks" plot, right the time when the view is loaded:
What are these memory leaking objects, detected by xCode Instruments?
. However these leaked objects are small, so I guess my app has other problems.
When my app continues to run, usually for 10+ rounds on an iPad 2, it then crashes. I don't much about Instruments yet, so I watch "All Heap Allocations". At the beginning of first round puzzle, the column "# Overall" is ~70k, it grows slowly between rounds of puzzles. When a new round puzzle comes in, it goes to ~90k, then round by round it reaches ~200k, then crashes.
Before crashes, in the log console I see memory warning and "CONNECTION INTERRUPTED".
I've followed a few things after searching memory leaking, such set NSArray/NSDictionary or mutable ones to nil, as much as possible (although not all of them, since some go between puzzles). I also changed UIImage imageNamed to [UIIMage alloc] initWithContentOfFile.
What else should I look/check to see what causes memory problem? TIA!
EDIT:
I wish I could post some codes that may be the suspect, but I really don't know what part to post. I should've check via Instruments in the course developing, so that I would know what caused the problem.
Regarding other view controllers. I do have others (menu, settings, app-store-rate, etc) and I generated all of them via code. My app doesn't have a storyboard or nib file. When I test crashes, I just click Next Puzzle button, so all other views will not show at all. So, before crash, the only view shown is the main view, with a few button, a few subviews, an animated pictures (but only the first puzzle as introduction). If it helps, here is my app:
http://itunes.apple.com/us/app/wordsect/id599455449?ls=1&mt=8
If you trying to debug application with Instruments - enable zombie detection mode:
In
Xcode: Product->Scheme->Edit Scheme
Select Debug scheme
Select Arguments tab bar on the scheme description
In Environments variables add and check NSZombieEnabled variable
Then when you start application under Instruments control, you'll get name of the instance, when your application crashed.

Real memory usage - MPFlipTransition

I am creating an app with an UIViewController which displays other UIViewControllers with the MPFlipTransition inside it. It's like a little book on iPad.
The UIViewControllers inside are created each with xibs with 4-5 UIImageViews inside and some of those images are animated with CoreAnimations ([UIView animateWithDuration] blocks)
I remove all the animations in the viewDidDiseappear function with the QuartzCore function removeAllAnimation on each animated layer.
But when I'm testing the app on an iPad 3, it works properly, but on iPad 2 it crashes at about the 8th page change.
I've made a profiling with Instruments and found that the real memory usage was increasing everytime I turned the page (when the MPFlipTransition appears). But even if I remove from the superview the previous views, the real memory usage is not decreasing. I thinks that it created the crash on the iPad 2 because the crash come when the real memory usage is passing the 400 Mbytes value (and the iPad 2 has only 512MB...).
What do you think about this problem ? Any help ? I'm using ARC for memory management...
Thanks for you help ! Feel free to ask if any need of precisions...

Is it possible that NSZombie doesn't point out EXC_BAD_ACCESS with ARC?

i'm currently working on an ios project with some people, one of us decided to use ARC in a part of the app.
Unfotunatly, we are currently experiencing some crashes when coming back from background.
Here are the steps we follow to crash the application, we perform them with the ios-simulator:
start the application
get on a ViewController A (coded with ARC)
get on a ViewController B (not coded with ARC -to be honest i don't
know if it's relevant-)
put the application in background.
simulate a memory warning (thx to the simulator)
start again the application, we'll be on the ViewController B
go back on the Viewcontroller A
the application crashes pointing the main function with an
EXC_BAD_ACCESS
We did try to use NSZombieEnabled to YES, but when we do it, the application doesn't crash and keeps running perfectly, so we wonder if it might be possible that NSZombieEnabled doesn't work well with ARC?
if anyone could give me a quick and clear insight about ARC and NSZombieEnabled that would be apreciated, i think i know how all of it works, but apparently i must be missing something.
Thanks anyway for your help and time.
Better than using the NSZombieEnabled, you should Profile the project, and use the Zombie instrument. When you do the same thing it should stop and say "zombie messaged", where you can click an arrow to see the class that is a zombie, and where it was allocated/deallocated.
I don't think the crash has to do with ARC, instead in viewDidUnload you are deallocating something, and then not setting a reference to nil - when you come back it tries to use the invalid reference.
Probably you would be better off if everything used ARC as it really helps to cure issues like this (the bug is very likely in the non-ARC code).

Resources