1

我有一个 OpenGL ES 活动,由于某种原因,即使在评论几乎每一行之后,它也会导致内存泄漏。这是剩下的代码

.h 文件

#import <UIKit/UIKit.h>
#import <GLKit/GLKit.h>

@interface PlayMain : GLKViewController <UIAccelerometerDelegate>{ }

@end

.m 文件

@interface PlayMain ()
{

}

@property (strong, nonatomic) EAGLContext *context;
@property (strong, nonatomic) GLKBaseEffect *effect;

@end

@implementation PlayMain{}

@synthesize context = _context;
@synthesize effect = _effect;

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1];
    if (!self.context)
    {
        NSLog(@"Failed to create ES context");
    }

    GLKView *view = (GLKView *)self.view;
    view.context = self.context;
    view.drawableDepthFormat = GLKViewDrawableDepthFormat24;
    [EAGLContext setCurrentContext:self.context];
}

- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect
{
}

在 openGL 活动和另一个活动之间进行大约 10-20 次切换后(它包含 3 个标签和一个按钮,用于创建回到 openGL 活动的 segue),应用程序会收到内存警告。如果我继续,那么在再切换几次之后,该过程就会终止。我错过了什么吗?

此外,我正在测试的设备是 ipod4,我在项目设置中使用 ARC。

4

0 回答 0