gallery - Android: OutofMemoryError: bitmap size exceeds VM budget with no reason I can see -


I have an outoffime with a gallery exception of 600x800 pixels on JPEG.


Environment

I am using the gallery around the 600x800 pixels gallery.

Since my content can only be a bit more complicated than images, I have set up each scene is a relative layout that wraps the image view with JPG.

In order to "sharpen" the user's experience, I have a simple cache of 4 slots, which is left about 1 image prefet (in a loop) to display the correct image. Image and place them in the 4 slots hashmap

platform

I am using a 600x800 screen with 256 RAM AVD and 128 heap size. It is also on the enterprise edge target, except that it is difficult to debug with the device.


Problem

I'm getting an exception:

  Out memory memory: bitmap size VM budget  

And this happens when getting the fifth image. I have tried to change the size of my image cache, and this is the same. Strange: memory should not be a problem

To ensure that Hep range is very important, I need it. Initially, a dummy 8 MB array is defined, and it has left it without reference, so it has been transmitted instantly. This activity is a member of the thread and is defined as the following

 < Code> static {@SuppressWarnings ("unused") byte dummy [] = new byte [8 * 1024 * 1 024]; }  

The result is that the size of the pile is approximately 11 MB and all of it is free. Note I said that this is the trick after the crash. It makes out-of-memory less often.

Now, I am using DDS. Before the accident (more does not change after the accident), DDMS shows:

  ID heap size allotted free% used # object 11.195 mb 2.428 mb 8.767 mb 21.69 % 47,156  

and in the detailed table it shows:

  type count total size smallest average average free 1,536 8.739 MB 16b 7.750 MB 24b 5.825KB  

The biggest block is 7.7 MB and even then Logcat says:

  error / heart Quikmem-Hep (1923): 925200-byte exterior process is very large for this process.  

If you take into account the average and average connection, it is reasonable to believe that most of the available blocks are very small, however, a block for bitmap Bigger, it's 7.7m. How is it still not enough?

Note: I discovered a heap, considering the amount of data allocated, it does not appear that more than 2m has been allocated. It matches the free memory report by DDMS.


  • Is it possible that I have a problem like patchwork?
  • How do I solve / solve the problem?
  • Is shared with lots of threads?
  • Could it be that I misread the DDS readout, and there really is no 900K block to allocate? If so, can someone tell me where I can see?

Thank you very much

Meymann

I think there is nothing special in your case. Not enough memory right now. You can not have many 600x800 bitmaps in memory, they consume a lot of memory. You should save them to SD and load them into memory on demand. I think that's exactly what you do.

One thing you should know: DDS displays Java HAP memory consumption. But there is also country memory which is not displayed in DDMS. And bitmap as far as I understand in native memory Therefore, DDMS is just a bad tool to track these memory issues. You need to make sure that you release your memory, you do not need them after collecting this image by the garbage collector.

Garbage collector works on his own program This is why you have bitmap on bitmap. Call the Recycle () method, which you do not need any more. This method eliminates the original memory that you take out. This way you do not depend on GC and you can release the largest piece of memory as soon as possible.

First of all, you should make sure that you do not leak a bitmap.

Here's a great deal on memory allocation, it can help you dig deeper


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -