0

In my viewcontroller i created a UIImageView and assigned a image in the Interface Builder. While checking on instruments i have allocation of malloc of 600kb and the responsible library is ImageIO_Malloc. But the size of my image is 37kb. I dont know why it allocates 600kb.

I have also tried with the code by assigning UIImage imageNamed. Still no good.

Do you people have any idea on that.

ipraba
  • 16,485
  • 4
  • 59
  • 58
  • alloc-ing/init-ing an object creates just that, an object. The size of memory allocated shouldn't really have anything to do with the size of the image. I really wouldn't worry about it unless you're not releasing it. – Thomas Clayson Dec 16 '10 at 13:55
  • I am releasing it correctly. But Whenever i move to another viewcontroller i assigned a image like this and for each viewcontroller this allocation rise my memory to many 600kbs – ipraba Dec 16 '10 at 13:58

1 Answers1

2

600 kB is really not much to allocate for a image. Your 37 kB is probably just the size of the compressed image file. However when that image needs to be displayed the image view needs to allocate back buffering of it so it can be represented in an uncompressed format internally.

An image with dimensions of 640x480 pixels will result in 300.000 pixels, each of which needs and R, G, B, and possible alpha value - meaning 3-4 bytes per pixel. So you can easily see allocations in the order og 600 kB for even fairly small images.

Claus Broch
  • 9,212
  • 2
  • 29
  • 38
  • So if i have five imageviews of 320x480 size i will get a allocation of 600x5 kbs of size. can i reduce those allocation sizes. – ipraba Dec 16 '10 at 15:32
  • Sure, make the dimension of the image smaller. Alternatively don't load the images you don't need in memory. – Claus Broch Dec 16 '10 at 23:40