Created
January 19, 2013 22:29
-
-
Save gfodor/4575611 to your computer and use it in GitHub Desktop.
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) | |
button = UIButton.buttonWithType(UIButtonTypeRoundedRect) | |
@window.addSubview(button) | |
button.frame = [[40,200],[200,50]] | |
button.addTarget(self, action:"leak_some_memory", forControlEvents:UIControlEventTouchDown) | |
@window.makeKeyAndVisible | |
true | |
end | |
def leak_some_memory | |
# Inline the "go" function here and the leak goes away. | |
# It seems the leak is due to the "data" binding being a function parameter? | |
go(Array.new(1024 * 1024 * 8)) | |
end | |
def go(data) | |
schedule_on_main do | |
puts "inside" | |
end | |
end | |
def schedule_on_main(*args, &blk) | |
::Dispatch::Queue.main.async &blk | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment