简体   繁体   中英

Memory leak in Mac OS X 10.7 AVCaptureScreenInput setCropRect: function

I'm working on a screen record app for Lion, which mainly use the Lion's new AVCaptureScreenInput class to get a screen video stream for a specified rect on the screen.Everything seems alright but:

According to the activity monitor, every time I call setCropRect: , the memory usage will increase by 10-20Mb . As I provide a feature that the rect size can be changed during recording, The memory usage could increase to 1-2Gb as user changes the rect a lot, which is a desaster:(

I seriously doubt if it is a bug in Apple's SDK, hence Apple's sample code AVScreenShack example has this problem either.

My code is just like this:

[m_AVCaptureSession beginConfiguration];
[m_AVScreenInput setCropRect:CGRectMake((int)grabRect.origin.x, (int)grabRect.origin.y,(int)grabRect.size.width, (int)grabRect.size.height)];
 [m_AVCaptureSession commitConfiguration];

Could anyone tell me, if it's a bug in the SDK, or I used it in the wrong way, or should I use another class to do this? THX

Since you're opening a configuration transaction, making the change, and then immediately committing the change, why not omit the transaction? It's possible that the library delays cleaning up transaction memory until the recording session is complete. I don't think it's necessary to use configuration transactions unless you need a group of configuration updates to be atomic.

Or it could be a genuine leak.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM