Blackberry memory limit for a screen? - blackberry

I wonder if there is some memory limit for the Mainscreen in BlackBerry? I mean I have like Garage Screen in my game and 60 cars + other images initiating and it seems loading time causes errors on real device, Bold 9700. Is it possible that the images cause memory errors? Total size of those images is about 2mb in /res folder.

Possibly. One work around you can try is do not load all the images in to memory at a time, instead, you can load the images as needed. This will be memory efficient.
Thanks
Naveen M

Related

iOS app crashes because images use too much ram

I know this is a stupid problem, but this is my first real app that I have to make, I have no one to ask and I looked up this problem and found no other similar problems.
My app crashes on real devices with no exception. I saw in the simulator that uses too much RAM and after a while I got to the conclusion that the pictures I am using are to blame.
The app is structured in this way: it has 8 viewControllers for different things: for example, it starts with one which lets the user select the avatar with which he/she will play and here I have two pictures, next is a viewController which shows the stats for that avatar and here it is another picture and so on. The problem is that each picture uses 40MB of RAM to be displayed and things add up so the app uses more than 300MB of RAM when the user gets to the gameviewCOntroller where the game is. Because of this, on devices like iPAD 2 or iphone 4 it crashes, but not on iphone 5.
I tried to set the images both from "images.xcassets" and from a ".atlas" folder, but the result is exactly the same. The pictures have a dimension of no more than 1500x1999px, they are in png format.
Also, I saw that if the app were to start directly into the gaveViewController it would use 180MB so the other viewController remain in memory or something like that. Should I "clear" them or something similar?
//-------update-------
This is what I got from Instruments:
Memory is a big deal on mobile devices, there is not a clear answer to you question, but I can give you some advices:
If your images are plain colors or have symmetric axes use resizable images. You can just use one line of pixel multiplied by with or height to cover the entire screen using a small amount of memory
Image compression doens't have effects when the image is decompressed. So if you have a png that is 600kb and you are thinking that converting in a 300kb will lower memory usage is only true for "disk space" when an image is decompressed in memory the size is widthXheightXNumber_of_channelXbit_for_channel
resize images: if are loading a 2000px square image into memory and you show it inside an image view of 800 px square, resize before adding it.You will have just a peak while resizing, but later it will use less memory
If you need to use big images, use tiling techniques such as CATiledLayer
If you don't need an image anymore get rid of it. It's ok to have an array of path to images, but not an array of full uncompressed images
Avoid -imageNamed it caches images and even if Apple says that this cache is released under memory pressure, you don't have a lot of control on it and it could be too late to avoid a crash
Those are general advices, it's up to you if they fit your requirements.
You should definitely follow Andrea's advices.
Additionally you should consider setting the image size to exactly what your need is. You're saying that you've tried to set them from xcassets so you have full control over the images you're loading, which is great (compared to downloading an image that you cannot modify).
I highly suggest you read some documentation on using Asset catalog files. This will allow you to have high-resolution image for bigger screens that also have more memory, and smaller ones for older devices, which is what you want here.
Also, note that 1500x1999px is still a very big size for most mobile devices.
More links about screen-size:
https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/MobileHIG/IconMatrix.html
http://www.paintcodeapp.com/news/iphone-6-screens-demystified

High memory usage in the app

I have an app that has 12 images contained in an array. All these images are displayed at the same time on the screen. (1 view - 12 much wider and higher images (UIImageView's) one on another. When user does something, app moves the images, thus the view displays different scenes)
The images themselves are not too heavy (it is about 2500x5000 in size, but the whole folder with images is around 3.5 MB).
After loading, the app consumes 355 MB.
When I put breakpoint in viewDidLoad (and all images are loaded at that time), xcode shows that the app consumes only 9 MB, but in viewDidAppear it is 355 MB.
What is the reason of it? And how can I store images compactly? (As I assume that the problem is in the images).
Thank you for any help!
An image open will occupy something like : H x W x number of channel x number of bit for channel, the file size is another thing, because images are compressed according to their type. Your images are 50Mb each one in memory.
The only way is to resize the image before displaing them. There are plenty of image resizing categories online, just google a little bit.
The other suggestion is to not load all the images togheter, just bring in the array the file path, and instantiate the image lazily.
If you need to use hires images you should look for CATiledLayer and tiling techniques.
These images probably cannot be displayed all at the same time onscreen, so you may want to load them only when necessary.
If you still need to display them all together onscreen, think about reducing their size.
Still, 355Mb is huge. Are you doing anything else in that application, that might use up all of that memory?
In Xcode go to Product->Profile. You will find there a lot of useful instruments which will help you to find problems with memory, CPU or battery usage. However, check it if you haven't seen it before.

Starling AS3: A lot of textures, memory warning iOS

I'm using the AssetManager class in Starling to load a lot of textures, around 600-700 png-files. All files are not loaded on start and I use multiple AssetManagers to hold the images. On start it loads around 70 images to 3 different managers and while it's loading I get some memory warnings on iOS.
iPhone appName[644] : Received memory warning.
iPhone appName[644] : Application received a memory warning from the system.
iPhone SpringBoard[74] : Received memory warning.
iPhone MobilePhone[199] : Received memory warning.
I've tried to load them at the same time and tried start each load when the other one is completed. I've also tried System.gc(); and System.pauseForGCIfCollectionImminent(0.1); between each load, this fixed the problem on iPhone 5 (7.0.4) but not on an iPhone 3gs (6.1.3).
Starling version: 1.4.1
Anyone got any tips on how to solve this?
Typically from a mobile development standpoint there is never a "one size fits all" solution. There are many different screen sizes and hardware configurations. In order to combat this many developers will generate -as mentioned previously, Sprite Sheets. Using this method the application only has to load one image vs -in your case hundreds. Image loaders take quite a while connecting to a memory address to initiate a texture upload to the GPU -I can't even image how slow it must be for that many assets.
This texture packer is phenomenal, and also aides with another feature many dev's incorporate. Asset Densities. Wherein the iPhone 3Gs a dev will load a set of sprite sheets developed for smaller screen sizes, a larger sprite sheet with twice the sized assets will load for a tablet or some of the higher end devices. This method will not only solve your memory issues but make your application look much better over a broader range of devices.
Here is a link to the Starling Wiki on multi-resolution development.
Of all the changes you can make to a project "for the better" the ones mentioned above are very high on the list.
You should NOT be loading 600-700 images. Even if they load successfully, you'll have a lot of problems with the performance. Instead, use atlas/sprite sheets.
http://wiki.starling-framework.org/manual/textures_and_images
And for even more optimized work, use ATF Textures instead png.
http://wiki.starling-framework.org/manual/atf_textures
If you run XCode Instruments against your app you'll see the total load of the device, which is the real metric that determines how often you receive memory warnings.
If your total load % is above 80%, expect a slew of constant memory warnings. The GC will try and run every time causing drastic clipping in framerate.
There's a bug about this and Adobe is working on it, but the main solution is to simply use less memory. Downscale textures for devices that have lower resolutions, etc...
https://bugbase.adobe.com/index.cfm?event=bug&id=3649713

iOS app with preloaded images

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.

Xcode instruments low memory warning app killed on 2 MB live bytes

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;

Resources