From 0a0113c516726de36513f342571a52997826a9de Mon Sep 17 00:00:00 2001 From: Leyman Maxim Date: Sun, 11 Feb 2024 01:09:25 +0300 Subject: [PATCH] memory leak fix --- src/graphics_capture_api.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/graphics_capture_api.rs b/src/graphics_capture_api.rs index 38957f0..26c26c9 100644 --- a/src/graphics_capture_api.rs +++ b/src/graphics_capture_api.rs @@ -367,11 +367,14 @@ impl GraphicsCaptureApi { impl Drop for GraphicsCaptureApi { fn drop(&mut self) { if let Some(frame_pool) = self.frame_pool.take() { + frame_pool.RemoveFrameArrived(self.frame_arrived_event_token).expect("Failed to remove Frame Arrived event handler"); frame_pool.Close().expect("Failed to Close Frame Pool"); } if let Some(session) = self.session.take() { session.Close().expect("Failed to Close Capture Session"); } + + self.item.RemoveClosed(self.capture_closed_event_token).expect("Failed to remove Capture Session Closed event handler"); } }