diff --git a/wrap.go b/wrap.go index 93d77a0..b3ce5d9 100644 --- a/wrap.go +++ b/wrap.go @@ -225,6 +225,7 @@ func (es *EventStream) start(paths []string, callbackInfo uintptr) { go func() { runtime.LockOSThread() es.rlref = CFRunLoopRef(C.CFRunLoopGetCurrent()) + C.CFRetain(C.CFTypeRef(es.rlref)) C.FSEventStreamScheduleWithRunLoop(es.stream, C.CFRunLoopRef(es.rlref), C.kCFRunLoopDefaultMode) C.FSEventStreamStart(es.stream) close(started) @@ -262,4 +263,5 @@ func stop(stream FSEventStreamRef, rlref CFRunLoopRef) { C.FSEventStreamInvalidate(stream) C.FSEventStreamRelease(stream) C.CFRunLoopStop(C.CFRunLoopRef(rlref)) + C.CFRelease(C.CFTypeRef(rlref)) }