Skip to content

Instantly share code, notes, and snippets.

@gfodor
Created January 19, 2013 22:29
Show Gist options
  • Save gfodor/4575611 to your computer and use it in GitHub Desktop.
Save gfodor/4575611 to your computer and use it in GitHub Desktop.
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