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-29-2010, 06:31 PM   #1 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 105
daveMac is on a distinguished road
Default UIGraphics Memory Leak

Hello there, I have a problem I just can't seem to figure out in my code. When I run my app using Instruments, I keep showing a memory leak. I didn't think that UIImages could leak, but that is what it is showing. I am really hoping that someone will be able to help me understand this and also give me an idea of how to fix it. Thanks in advance!

Code:
UIGraphicsBeginImageContext(test.size);  
	
	[image1 drawInRect:CGRectMake(0,0, test.size.width, test.size.height)]; 
	
	[image2 drawInRect:CGRectMake(0,0, test.size.width, test.size.height)]; 
	
//the next line is the leak	
	UIImage *resultingImage = UIGraphicsGetImageFromCurrentImageContext();
	
	UIGraphicsEndImageContext(); 

	return resultingImage;
daveMac is offline   Reply With Quote
Old 07-01-2010, 11:36 AM   #2 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 105
daveMac is on a distinguished road
Default

I figured out that the elusive memory leak isn't actually here, even though Instruments is showing that it is.

...just thought I would post this follow up in case someone stumbles into this thread and is still wondering.
daveMac is offline   Reply With Quote
Old 07-31-2010, 02:05 PM   #3 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 8
jowie is on a distinguished road
Question

Quote:
Originally Posted by daveMac View Post
I figured out that the elusive memory leak isn't actually here, even though Instruments is showing that it is.

...just thought I would post this follow up in case someone stumbles into this thread and is still wondering.
Interesting, because I'm definitely getting a leak from a similar piece of code:

Code:
UIGraphicsBeginImageContext(portraitView.bounds.size);
// this is the line that is causing the leak!
// if I comment it out, the leak goes away...
[portraitView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
jowie is offline   Reply With Quote
Old 08-01-2010, 03:53 PM   #4 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 105
daveMac is on a distinguished road
Default Keep looking...

Quote:
Originally Posted by jowie View Post
Interesting, because I'm definitely getting a leak from a similar piece of code:

Code:
UIGraphicsBeginImageContext(portraitView.bounds.size);
// this is the line that is causing the leak!
// if I comment it out, the leak goes away...
[portraitView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
Although this is where the leak is showing up, I can tell you from experience that most likely this isn't where you should be looking. Pay really close attention to the retain counts, and watch your releasing. I would be happy to try and help more, but you would need to post more code of how and where you are creating and using portraitView. Good luck.
daveMac is offline   Reply With Quote
Reply

Bookmarks

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: 327
7 members and 320 guests
anothermine, Chickenrig, Domele, givensur, michaelhansen, PixelInteractive, Sloshmonster
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:23 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0