Currently I am writing an iPad app. I am using a lot of images in this app around 40 MB of images!
This app works fine in simulator but crashing on device. I think the problem is with memory.
I wanted to know how much memory I can use on iPad?
Thanks
Saurabh
Remember that 40MB of image files on disk is far more when put in memory. On disk they are compressed but once you load it into memory you use just as much memory as a uncompressed image. If I remember right its (width x height x (bits per pixel/8)) = mem usage so for a full screen image (1024x768x(16/8)) = 1,572,864 so around 1.5 MB of RAM while on disk it may only be a couple hundred KB.
The iPad has 256 MB of memory, and of which, only around 100 to 120 are usable in an application. Note that this number is variable as the VM releases memory from previous applications, and could be less if you're using apps like iPod in the background.
My suggestion, look at what you can do to reduce the size of your images, through different resolutions, lower quality images, or such.
Related
I am creating a LibGDX based game and load assets with the Assetmanager.
All packed with Texturepacker.
For example level 1 has 96 pics with 9.78 mb disk space usage.
Level 2 has 226 pics with 17,4 mb disk space usage, not sifficant more.
I tested the game on Sony Z2 (Andoid 6) and Samsung Galaxy s7 (Android 7)
Now level 1 use on both devices ca. 140 mb RAM.
And level 2 use on s7 ca 90 mb and on Z2 600 mb.
How can it be that the older Phone use so much more RAM.
The GC should be the same or not?
Has anyone an idea?
ThankĀ“s for helping.
By the way,: Know everyone why the assets on drive use just 10 mb and ingame 120 mb?
Would be nice to know
I would not expect the GC on two different Android versions to behave identically. Nor on two different phones, even with the same version of Android.
Regarding your second question, image assets that you have saved as PNG or JPG are compressed, but OpenGL loads them uncompressed, so they take up a lot more RAM than the source files. A typical color image takes up four bytes of RAM per pixel, regardless of the source image size.
If you are really using too much RAM, you can look at using ETC1 compressed images, which stay compressed even after they are loaded. The downside besides the image degradation is that it doesn't work for images with any alpha transparency. Instructions are here in the LibGDX wiki.
The login view in our app uses large background images. To try and save on memory/app size I resized and compressed these images, which reduced their filesize significantly (less than 1mb, down from several mb).
When monitoring my apps memory usage (XCode debugger) there is a clear spike when a modified image is displayed (around 30-40mb). I'd accepted this as normal and simply made sure to release the image asap to limit memory usage.
I've recently started replacing a couple of the images and wanted to preview the new ones before resizing/compressing them. I noticed that these images (one of which is 11mb on disk and 4640x3472 pixels) has no visible effect on app memory usage whatsoever, increasing 'Other Processes' instead (by around 20-30mb).
Can anyone explain what's happening here? I want to confirm it is advisable to continue resizing/compressing the images.
Note that I'm loading the images using UIImage(contentsOfFile:) and I resized/compressed the images using GIMP. The new images have been taken straight from Flickr and unmodified.
Cheers.
The in-memory size of the image (as a UIImage) is different to the compressed on-disk size (your JPEG)
The UIImage takes 4 bytes (RGBA) per pixel x height x with - so for a 4640 x 3472 image, you're looking at 64,440,320 bytes - quite different to the 11MB on disk
I'm creating an iOS app with some preloaded data which includes images, it will have between 150 and 200 images. This images are not downloaded from a server, since the app won't connect to the internet.
I'm wondering about if saving the images locally can cause any problem, what is the max size that I can use to store them? Can this affect the app's performance? Anything else that I should be aware of?
Thanks in advance!
Over the air cellular maximum download is now 100MB since the iOS 7 launch.
Your maximum app size is 2GB with a maximum binary size of 60MB. With 200 images I don't think you'll hit the 2GB mark, so long as you use the proper compression techniques.
The only thing that would affect your app's performance is the way the images are presented. If they're really large images, 10+ MB you'll most likely hit memory problems in older devices and if you go larger, memory problems in newer devices. There's plenty of techniques like tiling in a scroll view to get around these problems but it requires you splice up your images and create multiple resolution versions of the image.
If your app is greater than 50MB (at the time of writing) because of the images being included then users will need WiFi to install it.
Other than that, your performance concerns should be around how many of the images you will have loaded into memory at any one time and how you can reduce that number.
My app crashes with low memory warning on device, even though the max live bytes in instruments is 3 MB tops. I do use a lot heavy PNG's in my app(in about 20 ViewControllers) , I believe ARC should've taken care of it.
Here is the screenshot.
Reduce size of heavy png files. Png file must be good in resolution but size must be less not more than 2 MB.I also had the same problem but used Three 20 Framework which solved my issue because it manages Images files allocation perfectly. Now a days it seem Three 20 is not getting updated but still you can try it in a sample app if you want . Here is the link :http://three20.info/
I figured it out myself. The problem was that I was doing animation using a bunch of PNG's.
So when using this
image.animationImages=imageFrames;
it was caching all the images in memory each time it was called, which led to dirty memory filling up and crashing the application. So, after using it each time to release the image cache we need to do this
image.animationImages=nil;
I'm working on an iOS app using PhoneGap. I ran into an annoying problem where some of my images weren't loading. Thinking it was a cache issue I played around swapping images.
I finally discovered that the issue had to do with the height of my image. After a whole bunch of trial and error I discovered that an image taller than 7864px will not load in the iPad simulator or the iPad itself. It will load fine in Safari. It's not a file size limitation as these are only 45k in size and I'm loading images that are 700k in size elsewhere without a problem.
Has anyone run into this? I can't find any documented restrictions on image dimensions within mobile Safari. If there are restrictions, knowing them would be handy.
For native apps, Apple says images larger than 2048x2048 1024x1024 are to be avoided and should be broken down into smaller ones. The problem here is not the file size on disk, but the size in memory: the image has to be decoded and turned into a "flat" representation.
So let's do some math: assume an image 5000x5000 pixels, with 8-bit RGB. This means each pixel occupies 3 bytes:
5,000 * 5,000 * 3 = 75,000,000 (roughly 71.5 MiB)
So you see your seemingly small image really fills up the memory very fast. iOS now cannot throw parts away if it's under memory pressure, it's the whole image or nothing.
Your only solution is break down the image into smaller parts. iOS can then remove images that aren't visible any more from memory (I doubt with such a huge image that all parts are visible all the time).