English 中文(简体)
静脉相传,特别是在有限的录像带上
原标题:ios memory leak in infinitely running application, particularly infinite video playback

I ve been doing a project which theoretically should work indefinitely. This means that you started the program, connect Ipad to power supply and it works for days, months, years etc. I was faced with the fact that whatever I do, the memory is gradually allocated, but not released. Instruments Leaks show the absence of memory leaks, but in Instruments Allocations and Activity Monitor memory is gradually allocated, it grows and grows. There are a lot of places where it occurs, particularly when playing videos A simple example (Xcode 4.3, no ARC):

www.un.org/Depts/DGACM/index_french.htm

@interface ViewController : UIViewController
{
    MPMoviePlayerController *player;

}

www.un.org/Depts/DGACM/index_french.htm

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];

    player = [[MPMoviePlayerController alloc] initWithContentURL:    [NSURL URLWithString:@"http://mysite.com/movie.mp4"]];

    player.view.frame = CGRectMake(400, 500, 360, 240);
    [self.view addSubview:player.view];
    player.controlStyle = MPMovieControlStyleNone;
    player.repeatMode = MPMovieRepeatModeOne;  
    [player play];
}

- (void)viewDidUnload
{
      [player stop];
      [player.view removeFromSuperview];
      [player release];
      [super viewDidUnload];
}

- (void)dealloc 
{
    [player release];
    [super dealloc];
}

This simple application does nothing more, just loop video playback. Every 3 minutes is allocated an average of 100kb. Every day - an average of 40MB. I m profiling with Instruments Activity Monitor. Over time, the app dies. Whats wrong? Why memory is growing, when I just watch video(loop playback) and not initialize new objects?

问题回答

预载投入流使用的切藏只有再次装满或关闭时,才能更新。 一旦你结束记忆并再次开启记忆任务,就赢得了“在那里”。 基本上不泄露记忆。

Also you need to remove MPMoviePlayerController notifications after it s use . You will also have to release the players object .

如果是你们使用[角色.view去除From Superview];





相关问题
How to change out-of-focus text selection color in Xcode?

Okay, I ll bite. I ve got really pleasant code/window colors set up in Xcode. Ordinarily, my selection color is very visible. When I am doing a project search and iterating through the results, ...

Iphone NSTimer Issue

Hi I am new to objective c. I am trying to make an app for iphone. I have a button on my view, and the click on which the function playSound is called. This is working properly. It does plays the ...

Include a .txt file in a .h in C++?

I have a number of places where I need to re-use some template code. Many classes need these items In a .h could I do something like: #include <xxx.txt> and place all of this code in the ....

Iterating over string/strlen with umlauted characters

This is a follow-up to my previous question . I succeeded in implementing the algorithm for checking umlauted characters. The next problem comes from iterating over all characters in a string. I do ...

Xcode open two editor windows with same file

Is it possible to open the same file in two separate windows in Xcode. I can open a file in one window and the same file in the main Xcode editor window, but I wanted two separate fulltime editor ...

Forcing code signing refresh in Xcode

In our environment, we share resources across multiple projects and platforms. When building for iPhone, only a subset of those resources are needed. Since that subset is still considerable, we have ...

热门标签