Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 06-01-2011, 09:30 PM   #1 (permalink)
Registered Member
 
Join Date: Dec 2009
Posts: 12
iSkythe is on a distinguished road
Default writeImageDataToSavedPhotosAlbum Slows Dramatically After A Few Uses

I save images to the iPhone's photo album using the api "writeImageDataToSavedPhotosAlbum". However, after several uses (such as 4), it begins to take approximately twice as long each time to save.

I have created a test method to reproduce it, where it saves the exact same image each time. The method is as follows:

Code:
-(IBAction)testButton {
    NSData *data = [NSData dataWithContentsOfFile:[[self photosDirectory] stringByAppendingPathComponent:[[self contentsOfPhotoDirectory] objectAtIndex:0]]];
    ALAssetsLibrary *al = [[ALAssetsLibrary alloc] init];
    __block NSDate *date = [[NSDate date] retain];
	[al writeImageDataToSavedPhotosAlbum:data metadata:nil completionBlock:^(NSURL *assetURL, NSError *error) {
        NSLog(@"Saving Time: %g", [[NSDate date] timeIntervalSinceDate:date]);
        [date release];
    }];
    [al release];
}
On a freshly restarted iPhone 4, I get the following save times.

2011-06-01 21:23:13.641 myapp[95:707] Saving Time: 5.30819
2011-06-01 21:23:17.101 myapp[95:707] Saving Time: 1.5311
2011-06-01 21:23:21.916 myapp[95:707] Saving Time: 2.52412
2011-06-01 21:23:25.974 myapp[95:707] Saving Time: 2.85623
2011-06-01 21:23:32.275 myapp[95:707] Saving Time: 4.93484
2011-06-01 21:23:42.024 myapp[95:707] Saving Time: 7.93288
2011-06-01 21:24:00.317 myapp[95:707] Saving Time: 15.8561
2011-06-01 21:24:33.199 myapp[95:707] Saving Time: 29.7571

What is wrong?

Last edited by iSkythe; 06-01-2011 at 09:35 PM.
iSkythe is offline   Reply With Quote
Old 06-01-2011, 10:25 PM   #2 (permalink)
Registered Member
 
Join Date: Dec 2009
Posts: 12
iSkythe is on a distinguished road
Default

After more investigating, I found the culprit was allocating memory but never releasing it. I had registered for the ALAssetsLibraryChangedNotification, and in the method that is called I allocated an instance of ALAssetsLibrary, but never released it after enumerating through it (I only released it in the failure block)
iSkythe is offline   Reply With Quote
Reply

Bookmarks

Tags
camera, saving, slow

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 333
5 members and 328 guests
Dnnake, iOS.Lover, jenniead38, pbart, Wikiboo
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,663
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, LezB44
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:17 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0