Reputation: 21
I face the problem, when I use the module desktop capture of the WebRTC to capture screen and mouse. NSCursor* nscursor = [NSCursor currentSystemCursor];
I found this line cause memory leak. That's a loop function in a thread, about 200ms to capture once.I don't know how to release the memory.
void MouseCursorMonitorMac::CaptureImage(float scale) {
NSCursor* nscursor = [NSCursor currentSystemCursor];
if (nscursor == nil) return;
NSImage* nsimage = [nscursor image];
if (nsimage == nil || !nsimage.isValid) {
return;
}
NSSize nssize = [nsimage size]; // DIP size
// No need to caputre cursor image if it's unchanged since last capture.
if ([[nsimage TIFFRepresentation] isEqual:[last_cursor_ TIFFRepresentation]]) {
return;
}
last_cursor_ = nsimage;
/*
others
/*
}
The fallow picture, I only remove all whithout NSCursor* nscursor = [NSCursor currentSystemCursor];
Upvotes: 2
Views: 232
Reputation: 104
I had similar issue when I had C++
project and it including Objective-C
code. To resolve issue I needed add @autoreleasepool
Upvotes: 2