iOS上的ZBar内存泄漏? [英] ZBar memory leak on iOS?

查看:201
本文介绍了iOS上的ZBar内存泄漏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对ZBar扫描性能非常满意,但是如果完全可信的话,我在ARC下运行的项目遇到了一个大问题。

I am very satisfied with ZBar scanning performance, however I ran into a big problem on a project that runs under ARC if that counts at all.

即使它似乎有一个严重的内存泄漏,随着readerView的每一个新显示器呈指数级增长。在大约10倍的内存使用率开始呈指数级增长并且大约20倍的扫描程序变得无法使用之后。

Namely, it seems that there is a serious memory leak that rises exponentially with each and every new display of the readerView. after some 10x memory usage starts to rise exponentially and around 20x scan program become unusable.

我见过使用相同版本构建的示例,并且没有任何问题。我也在readerView上尝试了方法flushCache,但它没有帮助。

I have seen example that are build with same version and there is no problem with it. I also tried method flushCache on readerView, but it doesn't help.

这是一个补丁: http://sourceforge.net/p/zbar/patches/36/ ,但我没有看到任何代码。由于我没有完整的源代码,我找不到它...

THere is one patch: http://sourceforge.net/p/zbar/patches/36/, but I don't see any code for it. Since I don't have full source code I cannot find it …

有没有人有同样的问题?

Has anybody had same problem?

推荐答案

我发现ZBar 0.10的当前稳定版本存在完全相同的问题,并通过继承ZBarReaderViewController并覆盖loadView方法来修复它。我现在可以反复运行扫描仪而不会让内存变得疯狂。

I found exactly the same problem with the current stable version of ZBar 0.10, and fixed it by subclassing ZBarReaderViewController and overriding the loadView method. I can now run the scanner over and over without memory going crazy.

以下是完整代码:

。 .. header

... header

#import <Foundation/Foundation.h>
#import "ZBarReaderViewController.h"

@interface CVZBarReaderViewController : ZBarReaderViewController
@end

..和实现

#import "CVZBarReaderViewController.h"

@implementation CVZBarReaderViewController 
- (void) loadView
{
    self.view = [[[UIView alloc] initWithFrame: CGRectMake(0, 0, 320, 480)] autorelease];
}
@end

请记住将.m文件标记为非-弧。转到项目设置/目标/构建阶段/编译源并使用-fno-objc-arc标记CVZBarReaderViewController.m。

Remember to mark the .m file as being non-arc. Go to Project Settings / Target / Build Phases / Compile Sources and mark CVZBarReaderViewController.m with -fno-objc-arc.

这篇关于iOS上的ZBar内存泄漏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆