Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get the memory size occupied by a image programatically in iphone sdk?

i want to print how much memory is occupying by a image when that particular image is loaded. can anyone have idea? Please help me Thank You Lakshmi

like image 475
Lakshmi Avatar asked Jun 19 '11 13:06

Lakshmi


1 Answers

UIImage provides no obvious way of telling the memory of the underlying data. However we could use Core Graphics to give us the estimate. You could probably get an estimate of the memory occupied by an image by doing

size_t imageSize = CGImageGetBytesPerRow(image.CGImage) * CGImageGetHeight(image.CGImage);

But I suggest you don't base any image management on this. You really don't know how much memory you will have with you. Try to minimize how many images you've loaded into memory. Basically, optimize as necessary.

like image 194
Deepak Danduprolu Avatar answered Nov 15 '22 08:11

Deepak Danduprolu