jPCT-AE - a 3d engine for Android > Support

ERROR/dalvikvm-heap(6950): Out of memory on a 1048592-byte a

<< < (3/4) > >>

Thomas.:
I never tried this, but maybe it can help
http://www.jpct.net/jpct-ae/doc/com/threed/jpct/util/BitmapHelper.html

buiminhhuy:
Thanks, i have been resolve my problem. No WARNING load texture and No Group heap is always increase.

Thanks  EgonOlsen very much.(sory because not read JavaDoc clearly). Thanks sir this days.
Thanks  Thomas very.

I have bean resolve my problem with snip code below:

--- Quote ---                             Drawable streets;
                  streets= new StreetsDrawable(lsGeo);               
                  Bitmap bitmap = Bitmap.createBitmap(IMG_WIDTH,
                          IMG_HEIGHT, Bitmap.Config.ARGB_8888);
                    Canvas c = new Canvas(bitmap);
                    streets.draw(c);
                                        Texture streetsTexture = null;
                    
--- Quote ---streetsTexture = new Texture(BitmapHelper.rescale(bitmap, 256, 256));   
--- End quote ---
                 
                    streetsTexture.setMipmap(true);
                    freeBitmap(bitmap);
                    if(tm.containsTexture("streets")){
                       tm.removeAndUnload("streets",fb);
                       tm.replaceTexture("streets",streetsTexture);
                    }else{
                       tm.addTexture("streets", streetsTexture);
                    }                  
--- End quote ---

buiminhhuy:

--- Quote ---01-31 01:49:08.209: INFO/StreetsDrawable(26528): Begin Draw Streets
01-31 01:49:08.219: INFO/StreetsDrawable(26528): 0----0
01-31 01:49:08.219: INFO/StreetsDrawable(26528): -279-----77
01-31 01:49:08.219: INFO/StreetsDrawable(26528): -1161-----222
01-31 01:49:08.219: INFO/StreetsDrawable(26528): The End Draw Streets
01-31 01:49:08.529: INFO/jPCT-AE(26528): Loading Texture...
01-31 01:49:08.569: DEBUG/lib_locapi(4670): loc_eng_report_status: GPS_STATUS_SESSION_BEGIN
01-31 01:49:08.679: DEBUG/dalvikvm(26528): GC_FOR_MALLOC freed 791 objects / 39288 bytes in 154ms
01-31 01:49:08.699: INFO/dalvikvm-heap(26528): Grow heap (frag case) to 21.244MB for 1048592-byte allocation

--- End quote ---

I can not understand why sometime Grow heap is increase when draw street, sometime  Grow heap is not increase . although I have been free memory of bimap and manager texture the same than every time draw street.

buiminhhuy:
i think i will use OpenGlES for draw street of me. Because Texture i can not free memory.

EgonOlsen:
After all, you can't control the garbage collector. You simply don't know when and why it collects garbage or not. System.gc(); doesn't enforce this by definition. It's just a hint. However, are you still getting OutOfMemory-Exceptions or are you just bothering with that heap-increase-message? I wrote myself a little test case that does this in each frame:


--- Code: ---cnt++;
if ((cnt & 2) == 0) {
Texture t=new Texture(1024, 1024, new RGBColor(cnt % 255, cnt % 255, cnt % 255));
t.setMipmap(true);
TextureManager.getInstance().unloadTexture(fb, TextureManager.getInstance().getTexture("texture"));
TextureManager.getInstance().replaceTexture("texture", t);
Logger.log("new Texture!");
}

--- End code ---

I.e. every second frame, it creates a new 4 MB large texture and replaces the former one with it. This runs without problems, the memory will be reclaimed as needed. However, i get a log message each time i'm doing this:


--- Code: ---01-30 19:55:04.288: INFO/dalvikvm-heap(491): Grow heap (frag case) to 14.706MB for 4194320-byte allocation

--- End code ---

...with exactly the same value of 14.706MB over and over again. So the VM prints out BS here IMHO, but it doesn't hurt. I don't see why it shouldn't work in your case unless the rest of what you are doing (canvas, drawable, bitmap...) is causing a problem somehow. I've read multiple times that working with Bitmap can cause memory leaks for example.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version