IOS Image Memory Usage

I want to know how iOS uses memory when displaying images ...

eg: I have an image that its 2000w, 2000h, but the iphone, ipod in this particular case has a 460x920 rectangle (just an example) ... if the image is just visible for the iOS device rectangle, I know for sure that memory is being used, but what happens with the rest of the image NOT FINALLY drawn in a rectangle? what memory is consumed? or is iOS smart enough not to use memory just for the drawn section? or is it considered a memory leak?

I'm wondering because in some games you need longer scripts with large images that use parallaxnodes or something similar. But I started to wonder how this affects my memory.

Thanks in advance for your answers.

+3


source to share


2 answers


On iPhone 4, you have 512MB of RAM. It is shared between the CPU and GPU, which means that the video memory consumes a portion of it.

If you're talking about UIImage

allocated 2000 by 2000 pixels. Even if it's off screen, it DOES consumes RAM. To be precise, it consumes 2000 * 2000 * 4, about 16 MB. The control is done using the Objective-c runtime. This is a fairly large amount. As far as I know, the maximum size UIImage

on Series 4 devices is 2048x2048 and 1024x1024 on 3 Series.

The view rectangle or screen you are talking about is part of the video memory. A typical display procedure involves composing an image in video memory for graphics hardware to display.



Hence, you have two copies of the image inside that 512MB of RAM. One of them can be loaded and changed by code (RAM), the other is smaller for display (VRAM). Although VRAM only uses screen size.

And no, this is not a memory leak.

+8


source


Yes, the whole image is loaded into memory. You can use things like CATiledLayer to control the image better.



+2


source







All Articles