Error 24 too many files open

Discussion in 'iOS Programming' started by 01.vipin, Oct 10, 2011.

  1. 01.vipin, Oct 10, 2011
    Last edited by a moderator: Oct 10, 2011

    01.vipin macrumors newbie

    Joined:
    Feb 22, 2011
    #1
    I am developing a small game app using Uikit + Uiimages. In the normal condition my app is running without any problem . but when i use rashly it will crash with the error

    <Notice>: ImageIO: CGImageRead_mapData 'open' failed '/var/mobile/Applications/01E69C96-CF79-466F-93AB-3A6752AF1295/PictureBook.app/NextPage.png'

    <Notice>: error = 24 (Too many open files).

    I am relesing all the image views and videos after usage. I tested my app with leak tool. There is no leaks also. No warnings, no potential leaks etc...

    I searched for a good answer, but i didn't get the appropriate answer yet. Anyone knows the answer , please reply. I posted some of the codes below.


    Code:
    - (NSMutableArray *)flowerArray {
    
    if (!_flowerArray) {
    
    _flowerArray = [[NSMutableArray alloc]init];
    
    for (int i = 1; i <= 5; i++) {
    
    UIImage *flowerIm = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"01_Flower_0%d.png",i] ofType:nil]];
    
    [_flowerArray addObject:flowerIm];
    
    [flowerIm release];
    
    }
    
    }
    
    return _flowerArray;
    }
    
    
    -(void)flowerImagesAnimate {
    
    self.flowerImage.animationImages = self.flowerArray;
    
    self.flowerArray = nil;
    
    self.flowerImage.animationDuration = 1.0;
    
    self.flowerImage.animationRepeatCount = 3;
    
    [self.flowerImage startAnimating];
    
    }
    
    
    
    -(void)playerPrepare
    {
    
    [self.view addSubview:[self.presentView playerPrepare]];
    
    }
    -(void)wakeUPPanjo
    {
    NSString *url = [[NSBundle mainBundle] pathForResource:@"01_Anim" 
    ofType:@"mp4"];
    
    NSURL *movieURL = [NSURL fileURLWithPath:url];
    
    
    
    self.presentView.player = [[MPMoviePlayerController alloc] 
    initWithContentURL:movieURL];
    
    
    
    
    [[NSNotificationCenter defaultCenter] 
    addObserver:self
    selector:@selector(movieFinishedCallback 
    name:MPMoviePlayerPlaybackDidFinishNotification
    object:self.presentView.player];
    
    [self.presentView.player prepareToPlay];
    
    [self performSelector:@selector(playerPrepare) withObject:nil afterDelay:0.5];
    
    wakeUpTimer = nil;
    
    
    }
    
    
    -(void)viewLoad
    {
    
    wakeUpTimer = [NSTimer scheduledTimerWithTimeInterval:videoDelay target:self selector:@selector(wakeUPPanjo) userInfo:nil repeats:NO];
    
    [self performSelector:@selector(flowerImagesAnimate) withObject:nil afterDelay:flowerPopupDelay];
    }
    
    - (void)viewDidLoad
    {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    [self performSelectorOnMainThread:@selector(viewLoad) 
    withObject:nil 
    waitUntilDone:false];
    }
     
  2. saving107 macrumors 603

    saving107

    Joined:
    Oct 14, 2007
    Location:
    San Jose, Ca
    #2
  3. 01.vipin thread starter macrumors newbie

    Joined:
    Feb 22, 2011
    #3
  4. xStep macrumors 68000

    Joined:
    Jan 28, 2003
    Location:
    Less lost in L.A.
    #4
    The only thing I notice is the you are not releasing self.flowerImage, so the opening to those files are still open, adding to your open file count.

    A side note; I wonder why you call viewLoad from viewDidLoad. I don't see any benefit to that.
     
  5. 01.vipin, Oct 10, 2011
    Last edited: Oct 10, 2011

    01.vipin thread starter macrumors newbie

    Joined:
    Feb 22, 2011
    #5
    I have release the self.flower image in dealloc . Sorry i didn't put that code here.
     

Share This Page