简体   繁体   English

Mac OS X 10.7中的内存泄漏AVCaptureScreenInput setCropRect:函数

[英]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: 我正在为Lion开发一个屏幕录制应用程序,该应用程序主要使用Lion的新AVCaptureScreenInput类来获取屏幕上指定rect的屏幕视频流。

According to the activity monitor, every time I call setCropRect: , the memory usage will increase by 10-20Mb . 根据活动监视器, 每次调用setCropRect: ,内存使用量将增加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:( 由于我提供了可以在录制过程中更改rect大小的功能,因此,随着用户对rect进行大量更改,内存使用量可能会增加到1-2Gb,这是一个灾难:

I seriously doubt if it is a bug in Apple's SDK, hence Apple's sample code AVScreenShack example has this problem either. 我严重怀疑这是否是Apple SDK中的错误,因此Apple的示例代码AVScreenShack示例也存在此问题。

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? 谁能告诉我,如果这是SDK中的错误,还是我以错误的方式使用了它,还是应该使用另一个类来做到这一点? 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. 否则可能是真正的泄漏。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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