diff options
author | Paul Rouget <me@paulrouget.com> | 2016-03-17 03:08:47 +0100 |
---|---|---|
committer | Paul Rouget <me@paulrouget.com> | 2016-03-17 03:08:47 +0100 |
commit | a3543b700f4982a470037cd059928aed533b887c (patch) | |
tree | 195e7f7b5604225f7d96dbed0fff9fdc347914e5 | |
parent | 3e9a5e711e10954f6e295d243f775aa4fdf02bee (diff) | |
parent | 08c311839f9c65faa358b0540a3ff6b2eb19ff14 (diff) | |
download | glutin-a3543b700f4982a470037cd059928aed533b887c.tar.gz glutin-a3543b700f4982a470037cd059928aed533b887c.zip |
Merge pull request #733 from fkaa/cocoa-memleak
Fix memory leak while creating NSEvent and swapping buffers (Fixes #514)
-rw-r--r-- | src/api/cocoa/mod.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/api/cocoa/mod.rs b/src/api/cocoa/mod.rs index 08fabdd..bec56d2 100644 --- a/src/api/cocoa/mod.rs +++ b/src/api/cocoa/mod.rs @@ -224,12 +224,16 @@ impl<'a> Iterator for PollEventsIterator<'a> { let event: Option<Event>; unsafe { + let pool = NSAutoreleasePool::new(nil); + let nsevent = NSApp().nextEventMatchingMask_untilDate_inMode_dequeue_( NSAnyEventMask.bits() | NSEventMaskPressure.bits(), NSDate::distantPast(nil), NSDefaultRunLoopMode, YES); event = NSEventToEvent(self.window, nsevent); + + let _: () = msg_send![pool, release]; } event } @@ -249,12 +253,16 @@ impl<'a> Iterator for WaitEventsIterator<'a> { let event: Option<Event>; unsafe { + let pool = NSAutoreleasePool::new(nil); + let nsevent = NSApp().nextEventMatchingMask_untilDate_inMode_dequeue_( NSAnyEventMask.bits() | NSEventMaskPressure.bits(), NSDate::distantFuture(nil), NSDefaultRunLoopMode, YES); event = NSEventToEvent(self.window, nsevent); + + let _: () = msg_send![pool, release]; } if event.is_none() { @@ -749,7 +757,11 @@ impl GlContext for Window { #[inline] fn swap_buffers(&self) -> Result<(), ContextError> { - unsafe { self.context.flushBuffer(); } + unsafe { + let pool = NSAutoreleasePool::new(nil); + self.context.flushBuffer(); + let _: () = msg_send![pool, release]; + } Ok(()) } |