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-11-2010, 05:09 PM   #1 (permalink)
Registered Member
 
Join Date: Mar 2010
Location: Cambridge, UK
Posts: 52
Werdan is on a distinguished road
Default ImageIO_Malloc

This is rather a clarifying question. I don't use specifically ImageIO anywhere in the program. All my images are PNG.

Yet, when I run the program through Instruments I get 600KB allocated to some ImageIo process. This is like 1/3 of what all the rest uses and I don't seem to have any intensive graphics

So I get the ImageIO_malloc inside copyImageBlockSetPNG... Maybe I am referring to all this wrongly, cause I have never used Instruments before, but I can't find anything on the topic and I would like to try to optimise my app. My images have lower size than 600KB, so don't get where this comes from...
Werdan is offline   Reply With Quote
Old 07-11-2010, 07:52 PM   #2 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by Werdan View Post
This is rather a clarifying question. I don't use specifically ImageIO anywhere in the program. All my images are PNG.

Yet, when I run the program through Instruments I get 600KB allocated to some ImageIo process. This is like 1/3 of what all the rest uses and I don't seem to have any intensive graphics

So I get the ImageIO_malloc inside copyImageBlockSetPNG... Maybe I am referring to all this wrongly, cause I have never used Instruments before, but I can't find anything on the topic and I would like to try to optimise my app. My images have lower size than 600KB, so don't get where this comes from...
I bet you're using UIImage imageNamed: to load PNG images. That method caches the images in case you use them again. I haven't tracked down what that looks like in instruments, but I bet that's what you're seeing. For comparison, imageWithContentsOfFile: doesn't cache image data.
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is offline   Reply With Quote
Old 07-12-2010, 05:34 AM   #3 (permalink)
Registered Member
 
Join Date: Mar 2010
Location: Cambridge, UK
Posts: 52
Werdan is on a distinguished road
Default

Quote:
Originally Posted by Duncan C View Post
I bet you're using UIImage imageNamed: to load PNG images. That method caches the images in case you use them again. I haven't tracked down what that looks like in instruments, but I bet that's what you're seeing. For comparison, imageWithContentsOfFile: doesn't cache image data.
Brilliant! Thanks a lot!
Werdan is offline   Reply With Quote
Old 07-12-2010, 06:29 AM   #4 (permalink)
Registered Member
 
Join Date: Mar 2010
Location: Cambridge, UK
Posts: 52
Werdan is on a distinguished road
Default

Quote:
Originally Posted by Duncan C View Post
I bet you're using UIImage imageNamed: to load PNG images. That method caches the images in case you use them again. I haven't tracked down what that looks like in instruments, but I bet that's what you're seeing. For comparison, imageWithContentsOfFile: doesn't cache image data.
I have changed all the imageNamed to what you have said and I still get this allocation. This is really strange. And it is more than just one allocation of 600KB.

It gets called once when I start the program, then when I display the popUp, and in smaller blocks (like 50KB) in many other cases.

Is there a way to trace all of this by memory addresses? How can I debug this?
Werdan is offline   Reply With Quote
Old 09-21-2010, 12:42 AM   #5 (permalink)
Registered Member
 
Join Date: Jan 2010
Posts: 4
henryaz is on a distinguished road
Default

I had the same problem. No matter how I created the UIImage (+imageNamed:, -initWithContentsOfFile:, +imageWithData: ), I could track the UIImages being alloc'd and dealloc'd, and also the UIImageViews doing the same. However, this malloc'd memory from ImageIO_Malloc that you mention kept adding up and was never freed - each with a retain count of "1" (according to Leaks instrument).

I decided to attack UIImageView. Getting rid of UIImageView and using my own view to draw the image immediately solved the problem:

Code:
@implementation HFImageView

- (id)initWithImage:(UIImage *)anImage
{
	CGRect frame;
	frame.origin = CGPointZero;
	frame.size = anImage.size;
	if (self = [self initWithFrame:frame]) 
	{
        // Initialization code
		image = anImage;
		[image retain];
		self.userInteractionEnabled = NO;
	}
	return self;
}


- (void)drawRect:(CGRect)rect 
{
	[image drawAtPoint:CGPointMake(0, 0)];
}

- (void)dealloc {
	[image release];
	[super dealloc];
}

@end
Worked with all three ways of creating the UIImage.

Last edited by henryaz; 09-21-2010 at 01:44 AM. Reason: Solved the problem
henryaz 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: 337
16 members and 321 guests
akphyo, alexP, appservice, cgokey, EXOPTENDAELAX, flamingliquid, guusleijsten, mariano_donati, ohmniac, Paul Slocum, PavelSea, SLIC, Sloshmonster, Sonuye857, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,653
Threads: 94,115
Posts: 402,888
Top Poster: BrianSlick (7,990)
Welcome to our newest member, ohmniac
Powered by vBadvanced CMPS v3.1.0

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