Core Data never releases NSData downloadable from external storage

Therefore, I use Core Datato store multiple images. (Also a subclass is created with the latter mogenerator)

(And also I use ARC)

Yes, I know that I can just store the link and store it on disk, but I thought:

"Hey, they made a choice so that I could do just that without having to manage it myself!"

So, I tried it and it works great, except that all the downloaded data is never released .


enter image description here

enter image description here


When initializing the ViewController, which will be responsible for displaying the images, I give it the usual main one NSManagedObjectContext.

And in the method called in viewDidAppear, I installed UIScrollViewwith images:

: , Entity1, -- , 1 . , .

- (void)setupScrollViewWithEntity1:(Entity1 *)entity1 {
    DDLogVerbose(@"-- %@ : SETUP SCROLL VIEW --", self);
    // I remove any previous subviews
    [self.scrollView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
    self.scrollView.contentSize = self.scrollView.frame.size;

    /* Here I get the imagesArray with a NSFetchRequest */ 
    //So it not really a fetch request I have an `Entity1` which have one-to-many with images and I use it to get the images
    NSSet *imagesSet = entity1.images;


    // So I have an NSArray holding all the Image object
    for (Image *image in imagesSet) {
        CGRect frame = self.scrollView.frame;
        frame.origin.x = image.numberValue*frame.size.width;
        UIScrollView *scrollView = [[UIScrollView alloc]initWithFrame:frame];
        scrollView.contentSize = self.scrollView.frame.size;
        UIImageView *imageView = [[UIImageView alloc]initWithFrame:self.scrollView.frame];
        imageView.image = [UIImage imageWithData:image.image];
        imageView.contentMode = UIViewContentModeScaleAspectFit;
        imageView.userInteractionEnabled = YES;
        [scrollView addSubview:imageView];
        scrollView.delegate = self;
        scrollView.minimumZoomScale = 1.0;
        scrollView.maximumZoomScale = 3.0;
        [self.scrollView addSubview:scrollView];
    }
}

}

viewWillDisappear NSManagedObjectContext, , dealloc'ed, , .

- , , : imageView.image = [UIImage imageWithData:image.image];

3 , , Instruments, , - .

, UIViewController dealloc 'ed, , Instruments Allocation, - , < > .


20 , dealloc'ed:

enter image description here


:

enter image description here

, , : (

+5
1

reset NSManagedObjectContext , ? . /db , .

+2

All Articles