Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6539555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:52:22+00:00 2026-05-25T10:52:22+00:00

I have the following code in my iPhone application, warning memory leak! This is

  • 0

I have the following code in my iPhone application, warning memory leak!

This is my code

-(IBAction)playVideo:(id)sender  {  
     NSString *filepath   =   [[NSBundle mainBundle] pathForResource:@"test" 
                                                              ofType:@"mov"];  
     NSURL    *fileURL    =   [NSURL fileURLWithPath:filepath];  
     MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
    [moviePlayerController.view setFrame:CGRectMake(38, 100, 250, 163)];  
    [self.view addSubview:moviePlayerController.view];  
    moviePlayerController.fullscreen = YES;  
    [moviePlayerController play];  
} 

This is the error message I’m getting:
Potential leak of an object allocated on line 37 and stored into ‘moviePlayerController’

I did try to autorelease “moviePlayerController” and then I try to release it. Both cases memory leak was solved but the video didn’t play on the iPhone! Strange please help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T10:52:23+00:00Added an answer on May 25, 2026 at 10:52 am

    The warning is correct: you are leaking the MPMoviePlayerController instance. But as you’ve discovered, you can’t effectively use the view without keeping the controller around.

    The solution is to store the MPMoviePlayerController into an ivar/property in your class, and then release it when you are done with its view (e.g. in viewDidUnload and dealloc).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: NSFileManager *fileManager = [NSFileManager defaultManager]; NSString *path1 = [[NSBundle
I have following code which works fine in iPhone application but in iPad I
So, I'm finishing up an iPhone App. I have the following code in place
I have following code in my application: // to set tip - photo in
I have following code in my Application. Comments in my code will specify My
I have following code in my application. [self.navigationController pushViewController:x animated:YES]; It will push a
I have following code in my application. NSData *data=[NSData dataWithContentsOfURL:[NSURL URLWithString:pathOfThumbNail]]; pathOfThumbNail has following
In my iPhone application, I have the following line in a constructor: self.myVar =
I'm developing an iPhone application. I have the following property: @property (nonatomic, retain) Point2D*
I have the following code in application didFinishLaunchingWithOptions where I want to present a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.