Last active
August 29, 2015 13:55
-
-
Save colinta/8693724 to your computer and use it in GitHub Desktop.
Hash.new memory leak
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AppDelegate | |
def application(application, didFinishLaunchingWithOptions:launchOptions) | |
@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds) | |
first = UINavigationController.alloc.initWithRootViewController(RootController.new) | |
first.pushViewController(TestController.new, animated: false) | |
first.pushViewController(TestController.new, animated: false) | |
first.pushViewController(WorkingController.new, animated: false) | |
@window.rootViewController = first | |
@window.makeKeyAndVisible | |
true | |
end | |
end | |
class RootController < UIViewController | |
end | |
class WorkingController < UIViewController | |
def viewDidLoad | |
puts "loaded WorkingController" | |
@hash = Hash.new(0) | |
end | |
def viewDidAppear(animated) | |
self.navigationController.popViewControllerAnimated(true) | |
end | |
def dealloc | |
puts "dealloc WorkingController" | |
super | |
end | |
end | |
class TestController < UIViewController | |
def viewDidLoad | |
puts "loaded TestController" | |
@hash = Hash.new do |hash,key| | |
hash[key] = 0 | |
end | |
end | |
def viewDidAppear(animated) | |
self.navigationController.popViewControllerAnimated(true) | |
end | |
def dealloc | |
puts "dealloc TestController" | |
super | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment