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 07-03-2010, 02:32 PM   #1 (permalink)
Registered Member
 
dabronx's Avatar
 
Join Date: Jun 2010
Location: Ashburn, VA
Posts: 27
dabronx is on a distinguished road
Default Memory Leak - UITableView - Image from CoreData

Hi - my first posting - been searching for help and trying not to post a dumb question, but can't find a solution...

I have the following code in my cellForRowAtIndexPath method:

Code:
NSMutableSet *rowSet = [oneObject mutableSetValueForKey: @"photos"];
		
// If the user has photos attached, sort them in the order they were added, and grab the first one...
if ([rowSet count] > 0) {
	NSMutableArray *rowArray = [NSArray arrayByOrderingSet:rowSet byKey:@"uniqueID" ascending:YES];
	
	// Get the first photo they added - use it as row image for table
	NSManagedObject *	relatedObject = [rowArray objectAtIndex:0];	

	// Assign the image to the cell
	cell.imageView.image = (UIImage*) [relatedObject valueForKey:@"photoData"];  
}
else
	[[cell imageView] setImage:self.emptyImage];
When I grab a photo from CoreData and assign it to the cell's ImageView.Image, it shows up just fine. If there are only a dozen or so rows that I scroll through, no problem. As soon as I scroll through the whole list of 50 or so rows, I start to get "Received memory warning. Level=1" and a few rows later - crash.

None of this happens in the simulator, nor does Instruments find any leaks...

If I copy the image from the ManagedObject to the Cell, using an intermediary GraphicContext type of thing, it works, and the leaks go away but it is painfully slow - too slow for actual usage...

Help!!! Please.
dabronx is offline   Reply With Quote
Old 07-04-2010, 04:57 AM   #2 (permalink)
Registered Member
 
dabronx's Avatar
 
Join Date: Jun 2010
Location: Ashburn, VA
Posts: 27
dabronx is on a distinguished road
Default Fixed

I "fixed" my problem by putting a thumbnail image in my main table instead of getting the first image from a related table - "photos". Now all the data being displayed in the cell is from the same NSManagedObject and things work fine... very strange...

Its also much faster (obviously) since I'm neither copying the image, nor referencing another table in my DB.

This forum and site are fabulous, by the way - I'd never have gotten as far as I have without constantly looking things up here.

Thanks!
dabronx is offline   Reply With Quote
Reply

Bookmarks

Tags
core data, memory leak, uiimage, uitableviewcell

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: 326
6 members and 320 guests
anothermine, Chickenrig, givensur, michaelhansen, PixelInteractive, stanny
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,118
Posts: 402,892
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

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