Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid Bitmap too heavy error
    primarykey
    data
    text
    <p>I have the following problem that some of you must know on my android app :</p> <blockquote> <p>3288-byte external allocation too large for this process.</p> <p>Out of memory: Heap Size=5959KB, Allocated=3922KB, Bitmap Size=18614KB</p> <p>VM won't let us allocate 3288 bytes</p> </blockquote> <p>Facts : </p> <ul> <li><p>I'm creating a bitmap of the screen (so quite huge) and I manipulate it (changing size etc ...) for doing a flipping page animation.</p></li> <li><p>It crashes only on a desire HTC : on galaxy s2 and kindle fire, no problems.</p></li> <li><p>I'm already desallocating the current Bitmap everytime I create a new one with the following code : </p> <p>Bitmap old = this.bitmap;</p> <pre><code>this.bitmap = bitmap; this.invalidate(); if(old != null) old.recycle(); </code></pre></li> <li><p>I also tryied to call this function :</p> <p>public void recycle() { if (this.bitmap!=null) this.bitmap.recycle(); System.gc(); Runtime.getRuntime().gc(); }</p></li> </ul> <p>Severals time in my code, and sometimes it gets slightly better (like it crashes a little later), but that's still not good.</p> <ul> <li>I spent a lot of time on this problem, and I don't really get how to fix it. It's like on forum there is a lot of misinformation, so I'm kinda lost.</li> </ul> <p>Thanks, ask for more precision.</p> <p>Edit : </p> <p>Here is a code called a lot :</p> <pre><code>//set the foreground image with the current day Bitmap b = Bitmap.createBitmap(visibleLayout.getWidth(), visibleLayout.getHeight(),Bitmap.Config.ARGB_8888); Canvas c = new Canvas(b); visibleLayout.draw(c); viewBitmapNext.setBitmap(b); viewBitmapNext.setVisibility(View.VISIBLE); </code></pre> <p>Where viewBitmapNext is an overwritted element of the View class. The setBitmap function is described above.</p> <p>About the resizement, I do this line of code : </p> <pre><code>viewBitmapPrevious.setLayoutParams(new RelativeLayout.LayoutParams((int) (iterator - ((totalWidth - iterator) - activity.getResources().getDimension(R.dimen.margin_right))/2), RelativeLayout.LayoutParams.WRAP_CONTENT)); </code></pre> <p>Again, tell me if you you want to know more.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload