Memory leak in WkWebView instantiation - ios

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.

Related

iOS 10 UIKit Zombie Crash, Worked Fine in iOS 7-9

We've got an app that's fairly large now, and we recently upgraded to iOS 10. In doing so, a new bug was introduced, and we're at a loss for how to solve it.
The crash itself occurs during a call to layoutIfNeeded(). However, the crash does not occur unless the layoutIfNeeded() call is contained inside a UIView.animateWithDuration() block. No amount of weak referencing, delays, or dispatch calls seems to have any effect. The same crash can be triggered during a call to [super viewWillTransitionToSizeWithTransitionCoordinator].
"An Objective-C message was sent to a deallocated 'Bubble' object (zombie) at address: 0x10924f030."
Enabling Zombies shows that we have a Release call going to one of our UIView subclasses, which we've named Bubble. Nothing too special there, some layout constraints and a gesture recognizer.
The Instruments app hasn't helped much, nor has the new visual memory debugger in Xcode 8 (though it is awesome, surprisingly little documentation on the feature).
I've included a screenshot of Zombies during the crash here. While I know the retain count can be misleading, there are certainly some confusing points to the trace, and we could really use some help diagnosing this.
Again, this code worked fine before iOS 10. We've been unable to find any notes from Apple about underlying changes to UIKit that may have had an effect.
Some more brief info: [Bubble cleanBubbles] simply iterates over the subviews of any view passed in, and removes the subview if its a Bubble class.
Apologies on certain violations of naming conventions, I'm sure there's plenty to criticize!
Thanks

Swift unbounded memory growth

I'm making a Swift 2.2 app in XCode7.3 using SpriteKit & GameCentre.
My issue is the memory used by the app continues to grow (an additional ~20MB is grabbed every second or so). Eventually this causes the app to crash due to memory issues. I get similar results running on a device (iPhone 6s) & simulator.
I've had a go at running it through Instruments (screenshot below) and this seems to show the issue.
Instruments screenshot
From digging into the instruments output, it seems to show a memory leak occurring off a 460 KiB malloc call. I haven't manage to isolate what's causing this from the stack trace.
Instruments output available - not certain how to attach it here. Any suggestions / pointers on where to start?
Try binary searching your code. Comment out half your calls. Still getting a memory leak? Ok, now you've reduced your search scope by half. Comment out half of the remainder. No memory leak? Great, you've just narrowed down your problem to 1 quarter of your code. Once you start getting the specific code that is causing the leak, you'll get much more useful answers out of StackOverflow.
Answer has been found - cause is a bug in the Apple/Spritekit code.
As part of setting up the scene I was setting showFields of the SKView to true. Once I disable this (false) the memory leak issue goes away.
From searching for this I found - https://forums.developer.apple.com/thread/27870

IOS7 - Xcode5 - Memory Leaks with NO CODE

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.

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