philemone / osmdroid

Automatically exported from code.google.com/p/osmdroid
0 stars 0 forks source link

MapTileCache Huge memory usage #394

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
MapTileCache in MapTileProviderBase use too much memory.

OpenStreetMapViewer became unresponsive after several zoom-in-zoom-out on 
emulator with 1GB RAM and 16MB heap because of OutOfMemory.

Is it possible to reduce this size? Maybe save tiles in cache in some 
compressed form?

I tried to extend XYTileSource so that it returns Bitmap in RGB_565. This 
reduces size by factor of 2. It is much better, but memory consumption is still 
high.

hprof leakhunter:
One instance of "org.osmdroid.tileprovider.MapTileProviderBasic" loaded by 
"dalvik.system.PathClassLoader @ 0xb6657d68" occupies 6 037 936 (40,30%) bytes. 
The memory is accumulated in one instance of 
"org.osmdroid.tileprovider.LRUMapTileCache" loaded by 
"dalvik.system.PathClassLoader @ 0xb6657d68".

Accumulated Objects:
Class Name  Shallow Heap    Retained Heap   Percentage
org.osmdroid.tileprovider.MapTileProviderBasic @ 0xb6690e88 32  6037936 40,30%
org.osmdroid.tileprovider.MapTileCache @ 0xb6692338 16  6036056 40,29%
org.osmdroid.tileprovider.LRUMapTileCache @ 0xb6692ec0 64   6036040 40,29%
java.util.LinkedHashMap$LinkedEntry @ 0xb6647e60 32 262424  1,75%
java.util.LinkedHashMap$LinkedEntry @ 0xb66480a8 32 262424  1,75%
java.util.LinkedHashMap$LinkedEntry @ 0xb664fe48 32 262424  1,75%
java.util.LinkedHashMap$LinkedEntry @ 0xb66539a0 32 262424  1,75%
java.util.LinkedHashMap$LinkedEntry @ 0xb6656690 32 262424  1,75%
java.util.LinkedHashMap$LinkedEntry @ 0xb6659600 32 262424  1,75%
java.util.LinkedHashMap$LinkedEntry @ 0xb665e358 32 262424  1,75%
java.util.LinkedHashMap$LinkedEntry @ 0xb665f948 32 262424  1,75%
java.util.LinkedHashMap$LinkedEntry @ 0xb6663088 32 262424  1,75%
java.util.LinkedHashMap$LinkedEntry @ 0xb66633f0 32 262424  1,75%
java.util.LinkedHashMap$LinkedEntry @ 0xb6678ca8 32 262424  1,75%
java.util.LinkedHashMap$LinkedEntry @ 0xb6685f10 32 262424  1,75%
java.util.LinkedHashMap$LinkedEntry @ 0xb6686388 32 262424  1,75%
java.util.LinkedHashMap$LinkedEntry @ 0xb668faf8 32 262424  1,75%
java.util.LinkedHashMap$LinkedEntry @ 0xb6690620 32 262424  1,75%
java.util.LinkedHashMap$LinkedEntry @ 0xb6693050 32 262424  1,75%
java.util.LinkedHashMap$LinkedEntry @ 0xb66937a0 32 262424  1,75%
java.util.LinkedHashMap$LinkedEntry @ 0xb66c3380 32 262424  1,75%
java.util.LinkedHashMap$LinkedEntry @ 0xb66c3f40 32 262424  1,75%
java.util.LinkedHashMap$LinkedEntry @ 0xb66d1998 32 262424  1,75%
Total: 20 entries

Emulator logcat: 
I/dalvikvm( 1423): 
I/dalvikvm-heap( 1423): Clamp target GC heap from 16.952MB to 16.000MB
D/dalvikvm( 1423): GC_FOR_ALLOC freed 32K, 7% free 15256K/16327K, paused 8ms
I/dalvikvm-heap( 1423): Forcing collection of SoftReferences for 262156-byte 
allocation
I/dalvikvm-heap( 1423): Clamp target GC heap from 16.952MB to 16.000MB
D/dalvikvm( 1423): GC_BEFORE_OOM freed <1K, 7% free 15255K/16327K, paused 4ms
E/dalvikvm-heap( 1423): Out of memory on a 262156-byte allocation.
I/dalvikvm( 1423): "downloader" prio=5 tid=21 RUNNABLE
I/dalvikvm( 1423):   | group="main" sCount=0 dsCount=0 obj=0xb6b9d4b8 
self=0x8f74cd8
I/dalvikvm( 1423):   | sysTid=1457 nice=0 sched=0/0 cgrp=[fopen-error:2] 
handle=150419256
I/dalvikvm( 1423):   | schedstat=( 0 0 0 ) utm=107 stm=19 core=0
I/dalvikvm( 1423):   at 
android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
I/dalvikvm( 1423):   at 
android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:493)
I/dalvikvm( 1423):   at 
android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:549)
I/dalvikvm( 1423):   at 
org.osmdroid.tileprovider.tilesource.BitmapTileSourceBase.getDrawable(BitmapTile
SourceBase.java:130)
I/dalvikvm( 1423):   at 
org.osmdroid.tileprovider.modules.MapTileDownloader$TileLoader.loadTile(MapTileD
ownloader.java:207)
I/dalvikvm( 1423):   at 
org.osmdroid.tileprovider.modules.MapTileModuleProviderBase$TileLoader.run(MapTi
leModuleProviderBase.java:246)
I/dalvikvm( 1423):   at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
I/dalvikvm( 1423):   at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
I/dalvikvm( 1423):   at java.lang.Thread.run(Thread.java:856)

Original issue reported on code.google.com by ls.illar...@gmail.com on 10 Jan 2013 at 4:27

Attachments:

GoogleCodeExporter commented 8 years ago
Any luck with replies to this issue? I'm too facing this. My GC_FOR_ALLOC is 
constantly being called.

Original comment by Suraj.kv.blog@gmail.com on 14 May 2014 at 5:05