Skip to content

Terminated due to memory issue #2550

Open
@Neil20170220

Description

@Neil20170220

I try to export video with GPUImageColorInvertFilter for infinite times, momery occupy by Other processes increase continuously, and the App is killed finally.

I test use iPhone 8, iOS 11.2.1, Xcode 9.2.

Here is my code:

- (void)export {
    self.index++;
    
    NSLog(@"------ loop %lu begin ------", self.index);
    
    NSURL *sampleURL = [[NSBundle mainBundle] URLForResource:@"Video-20171220-121803" withExtension:@"MP4"];
    
    self.movieFile = [[GPUImageMovie alloc] initWithURL:sampleURL];
    self.filter = [[GPUImageColorInvertFilter alloc] init];
    
    [self.movieFile addTarget:self.filter];
    
    NSString *documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
    NSDate *now = [[NSDate alloc] init];
    NSString *pathToMovie = [NSString stringWithFormat:@"%@/%@.mp4", documentsPath, now];
    
    NSURL *movieURL = [NSURL fileURLWithPath:pathToMovie];
    
    self.movieWriter = [[GPUImageMovieWriter alloc] initWithMovieURL:movieURL size:CGSizeMake(3280, 2460)];
    [self.filter addTarget:self.movieWriter];
    
    self.movieWriter.shouldPassthroughAudio = YES;
    self.movieFile.audioEncodingTarget = self.movieWriter;
    [self.movieFile enableSynchronizedEncodingUsingMovieWriter:self.movieWriter];
    
    [self.movieWriter startRecording];
    [self.movieFile startProcessing];
    
    __weak typeof(self) weakSelf = self;
    [self.movieWriter setCompletionBlock:^{
        [weakSelf.movieWriter finishRecordingWithCompletionHandler:^{
            [weakSelf.movieFile endProcessing];
            [weakSelf.movieWriter endProcessing];
            
            [weakSelf.movieFile removeAllTargets];
            [weakSelf.filter removeAllTargets];
            
//            [weakSelf.movieWriter.movieWriterContext.framebufferCache purgeAllUnassignedFramebuffers];
//            [[GPUImageContext sharedFramebufferCache] purgeAllUnassignedFramebuffers];
            
            weakSelf.movieFile = nil;
            weakSelf.movieWriter = nil;
            weakSelf.filter = nil;
            
            NSLog(@"------ loop %lu end ------", weakSelf.index);
            
            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                [weakSelf export];
            });
        }];
    }];
}

Console log:

2017-12-21 10:56:24.201511+0800 TestGPUImage[5681:507472] [DYMTLInitPlatform] platform initialization successful
2017-12-21 10:56:24.424024+0800 TestGPUImage[5681:507322] ------ loop 1 begin ------
2017-12-21 10:56:24.472424+0800 TestGPUImage[5681:507322] Metal GPU Frame Capture Enabled
2017-12-21 10:56:24.473832+0800 TestGPUImage[5681:507322] Metal API Validation Enabled
2017-12-21 10:56:36.244905+0800 TestGPUImage[5681:507462] ------ loop 1 end ------
2017-12-21 10:56:37.345201+0800 TestGPUImage[5681:507322] ------ loop 2 begin ------
2017-12-21 10:56:48.757717+0800 TestGPUImage[5681:507494] ------ loop 2 end ------
2017-12-21 10:56:49.855167+0800 TestGPUImage[5681:507322] ------ loop 3 begin ------
2017-12-21 10:57:01.295918+0800 TestGPUImage[5681:507504] ------ loop 3 end ------
2017-12-21 10:57:02.395126+0800 TestGPUImage[5681:507322] ------ loop 4 begin ------
2017-12-21 10:57:13.619635+0800 TestGPUImage[5681:507462] ------ loop 4 end ------
2017-12-21 10:57:14.715098+0800 TestGPUImage[5681:507322] ------ loop 5 begin ------
2017-12-21 10:57:26.126941+0800 TestGPUImage[5681:507494] ------ loop 5 end ------
2017-12-21 10:57:27.225068+0800 TestGPUImage[5681:507322] ------ loop 6 begin ------
2017-12-21 10:57:38.677026+0800 TestGPUImage[5681:507494] ------ loop 6 end ------
2017-12-21 10:57:39.777085+0800 TestGPUImage[5681:507322] ------ loop 7 begin ------
2017-12-21 10:57:51.205614+0800 TestGPUImage[5681:507462] ------ loop 7 end ------
2017-12-21 10:57:52.304992+0800 TestGPUImage[5681:507322] ------ loop 8 begin ------
2017-12-21 10:58:03.683542+0800 TestGPUImage[5681:507553] ------ loop 8 end ------
2017-12-21 10:58:04.777104+0800 TestGPUImage[5681:507322] ------ loop 9 begin ------
2017-12-21 10:58:16.195421+0800 TestGPUImage[5681:507553] ------ loop 9 end ------
2017-12-21 10:58:17.294912+0800 TestGPUImage[5681:507322] ------ loop 10 begin ------
2017-12-21 10:58:28.737305+0800 TestGPUImage[5681:507938] ------ loop 10 end ------
2017-12-21 10:58:29.837053+0800 TestGPUImage[5681:507322] ------ loop 11 begin ------
2017-12-21 10:58:41.274280+0800 TestGPUImage[5681:507504] ------ loop 11 end ------
2017-12-21 10:58:42.370562+0800 TestGPUImage[5681:507322] ------ loop 12 begin ------
2017-12-21 10:58:53.802709+0800 TestGPUImage[5681:507494] ------ loop 12 end ------
2017-12-21 10:58:54.894791+0800 TestGPUImage[5681:507322] ------ loop 13 begin ------
2017-12-21 10:59:06.392834+0800 TestGPUImage[5681:507553] ------ loop 13 end ------
2017-12-21 10:59:07.488873+0800 TestGPUImage[5681:507322] ------ loop 14 begin ------
2017-12-21 10:59:19.582711+0800 TestGPUImage[5681:507553] ------ loop 14 end ------
2017-12-21 10:59:20.674655+0800 TestGPUImage[5681:507322] ------ loop 15 begin ------
2017-12-21 10:59:32.168117+0800 TestGPUImage[5681:507494] ------ loop 15 end ------
2017-12-21 10:59:33.264523+0800 TestGPUImage[5681:507322] ------ loop 16 begin ------
2017-12-21 10:59:44.743873+0800 TestGPUImage[5681:507504] ------ loop 16 end ------
2017-12-21 10:59:45.838880+0800 TestGPUImage[5681:507322] ------ loop 17 begin ------
2017-12-21 10:59:57.344725+0800 TestGPUImage[5681:507462] ------ loop 17 end ------
2017-12-21 10:59:58.444451+0800 TestGPUImage[5681:507322] ------ loop 18 begin ------
2017-12-21 11:00:09.973719+0800 TestGPUImage[5681:508769] ------ loop 18 end ------
2017-12-21 11:00:11.067642+0800 TestGPUImage[5681:507322] ------ loop 19 begin ------
2017-12-21 11:00:22.619509+0800 TestGPUImage[5681:507553] ------ loop 19 end ------
2017-12-21 11:00:23.714545+0800 TestGPUImage[5681:507322] ------ loop 20 begin ------
2017-12-21 11:00:35.369409+0800 TestGPUImage[5681:508769] ------ loop 20 end ------
2017-12-21 11:00:36.464379+0800 TestGPUImage[5681:507322] ------ loop 21 begin ------
Message from debugger: Terminated due to memory issue

dingtalk20171221110012

Can any one help? thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions