OutOfMemoryError: bitmap size exceeds VM budget in android - android-widget

i am facing a problem of OutOfMemoryError that is bitmap size exceeds vm budget .When I load image in listView ,First 10 image load proper but we click next button for next 10 images .This error OutOfMemoryError: bitmap size exceeds VM budget in android
How can i resolve this problem, any one please solve this problem. Thanks

When you go to the next 10 images do you delete the first 10 to free up the memory? Otherwise you're program needs more and more memory until it's up. Is this an android app you might want to make the images smaller so it doesn't consume so many memory.

Please use this " android:largeHeap="true" in application Tag of your app's Manifiest.xml file.
Your OutOfMemoryError issue May be solve out.

Related

What happens if my image is greater than maxSize for Firebase Storage?

I couldn't find the answer to this elsewhere. What happens if the image size is greater than maxSize for Firebase Storage?
For example, in my app, I store images on the server and the user can download them later, if desired. When I call the getData with the maxSize option set to 1 * 1024 * 1024, I get the following error on a few of the images:
Attempted to download object with size of 1059073 [example] bytes, which exceeds the maximum size of 1048576 bytes.
I get it... the photo is bigger than the maxSize I set. What I'm wanting to know is even though it's bigger than the maxSize, what happens? Does the image get compressed over and over until it finally meets the maxSize threshold and is then downloaded? Does the image get skipped all together and not downloaded because it's too large?
How can I compress the images to a small enough size when uploading? The solutions I've tried must be outdated, because they don't work very well. I know that's a separate question, but if you don't mind answering it as well then great... two birds with one stone - if not, then oh well.
The error says to "Consider raising the maximum download size." How do I know how high I can raise it without slowing the app down or causing an issue??
Please explain your answers with code or a link!
Thanks.
What I'm wanting to know is even though it's bigger than the maxSize, what happens?
The file does not get downloaded, as it's bigger than the maximum size you've reserved for it. Aside from that, nothing happens.
Does the image get compressed over and over until it finally meets the maxSize threshold and is then downloaded?
Definitely not. Firebase Storage knows nothing about your files on its own, so it doesn't touch them in any way. There may be add-on products (such as Extensions) that can resize images, but those are not triggered by the condition you have.
If you're having trouble making a resizing solution work, open a new question with the minimum steps with which anyone can reproduce where you are stuck.

iPhone Application Memory Issue

I have created an iPhone Application where I have managed to handle leaks using the Profiling tool of XCode.
I have a gallery of images shown in UIScrollview when I load the view.Images in the gallery changes on each load of the view of iPhone.
I managed to remove the leaks using the profiler, but what happens now is memory gets increased by some amount on each load. I really cannot get why the memory increases on each load,when there are no leaks in the application.
Can anybody help me in finding this issue?
If you don't have leaks in the app it does not mean that your memory management logic is correct.:d
Do an analyze from tools menu.
And read again your code to see where you can release objects that are no longer needed.
In a gallery you should load only what users sees and the previous and next image only one step.
So if you are displaying one image on screen load only the next and the previous if you have one. So you will have only 2 or 3 images alive in memory. When user scrolls load next and release the previous, you can cash more than one image like 2 3 4 depending on the size,

CCSprite memory overflow

I need to create and show 10 images using cocos2d. Each will be placed above previous one and all will be visible simultaneously (all of them has transparent areas). Each image has resolution 2048x1536.
When I create 5 or less CCSprites the app run fine, but when I create 6 CCSprite - it crashes on device (iPad) with error "Data Formatters temporary unavailable".
I suppose it's lack of memory, but maybe someone knows any approach for for this situation
Thanks!
A transparent image of this size uses about 12mb ram (2048*1536*4 bytes).
You are lucky that you get 5 images of this size shown before your app crashes.. which usually happens at about 50mb ram usage.
Without more knowledge about what you want to do or need to display I can't give any advice what to do .. but you won't be able to show 10 images of this size.
edit: since you are using cocos/opengl you might be able to get more images shown by changing the image format to rgb4444. This will cut the memory need to the half but you also loose much quality on your images.

Images showing in simulator but not on the iPhone device

So when I run the application from the device the pictures show up and everything works great. However, when I move to the device I run in about 10 out of 38 pictures that don't show up. I am pulling the names for the images from an sqlite database and I already checked and the names are correct, case and everything. I checked the bundle and the images are correctly in there.
Does memory play into effect in this? I am not really sure what else could cause this to happen??
Thanks!
Solution:
The files somehow were not saved properly and were unable to be opened by say photoshop or paint even. So with the files not being able to be open they weren't showing up... Thanks for the help everyone!
First thing to check is the case of the strings you're using to refer to the resources. The iPhone is case sensitive, but the simulator is not.
Oops, just seen that you checked the case. Better log all your UIImage creation calls then!
The simulator accepts a wider range of image formats. Sometimes you had a specific file type that the device cannot display. Double check the 10 files looking for some difference from the others ones.
Yes, memory absolutely plays into this. Check your UIImage creation calls and make sure they dont return empty. Also, check to see if youre getting memory warnings in the console window.
Generally, if in-memory size was the culprit, your application would crash with a low memory error on the device. However, it seems like the images just don't display.
One other thing that can be going wrong is the size of the images. UIViews on the iPhone can only have dimensions smaller than the maximum texture size supported by the GPU. Apple states that this is 1024 x 1024, but I've found it to be more like 2048 x 2048 on even the original model iPhone. You may be creating a view for some of these images that exceeds this size in one dimension, but your Mac has a larger maximum texture size on its GPU and so it displays fine in the Simulator.
Apparently the iPhone caches the launch screens. So in my case, I had to reboot my iPhone before being able to see the image.

How to solve Memory Warning Level-1,then Memory Warning Level-2?

I am using apple standard code for scrolling+zooming+paging after 10 image scrolling and paging my console gives Memory Warning Level-1,Then Memory Warning Level-2 and then crash how can i stop crash my application?Please help me.I have taken this code from http://developer.apple.com/library/ios/#samplecode/PhotoScroller/Introduction/Intro.html
Did you implement the -(void)didReceiveMemoryWarning ? You can release every images that you don't use at this moment.
Keeping all images in an array will prevent you of doing this. Instead, you should create a method that gives you the right image based on its index (like an array) but that manages a cache (i.e. using an array) that you can clean when memory warnings are issued. Also I don't know this sample project by heart but I guess that they use only three controls to display image on the left, current image and image on the left. If not, be sure that other views are released when not useful for display.
It seems the images you use is of greater size.Try to reduce the pixel size and use it.
All the Best.
Each big image must be treated as a set of tiles and load data from the ONLY tile or set of tiles which is / are currently being displayed on the screen.
I dont know exactly how this works but you can google for it, I guess.