PATRIK27 / osmdroid

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

Out of memory when Rotating Display using Jar and xytilesource #277

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. include jar in project
2. open map using xytilesource (and if you want it to fail really fast you an 
xytilesource as a tileoverlay also)
3. rotate screen a few times

What is the expected output? What do you see instead?
Expected: no issues
Instead: map partially loads, app freezes and logcat shows out of memory 
errors/ or GC_FOR_MALLOC errors over and over

What version of the product are you using? On what operating system?
osmdroid-android-3.0.5.jar

Please provide any additional information below.

The bug is most likely related to whateve 
http://code.google.com/p/osmdroid/issues/detail?id=27 and 
http://code.google.com/p/osmdroid/issues/detail?id=54

I tested the rotation using the built in open street maps and it didn't crash

Original issue reported on code.google.com by jpetti...@gmail.com on 1 Dec 2011 at 10:45

GoogleCodeExporter commented 8 years ago
as extra information that I forgot (and I'm not sure if it makes a difference), 
I am using an mbtiles file as the source for the xytilesource

Original comment by jpetti...@gmail.com on 1 Dec 2011 at 10:51

GoogleCodeExporter commented 8 years ago
After some more research I am not sure the problem is necessarily related 
directly to xytilesource. As I am completely lost as to what is causing it now, 
here is the code i use to set up the map

                     ResourceProxy mResourceProxy = new DefaultResourceProxyImpl(getApplicationContext());
                     SimpleRegisterReceiver simpleReceiver = new SimpleRegisterReceiver(this);
                     File f = new File("path to mbtiles file");
                     XYTileSource MBTILESRENDER = new XYTileSource(
                    "mbtiles",
                    ResourceProxy.string.offline_mode,
                    minZoom, maxZoom, // zoom min/max
                    256, ".png", "http://i.dont.care.org/");

            IArchiveFile[] files = { CustomMBTilesFileArchive.getDatabaseFileArchive(f) }; //custommbtilesfilearchive is just my fix for issue 254 (linked after code) since that has not been built into the jar yet
            MapTileModuleProviderBase moduleProvider = new MapTileFileArchiveProvider(simpleReceiver, MBTILESRENDER, files);
            mProvider = new MapTileProviderArray(MBTILESRENDER, null, new MapTileModuleProviderBase[]{ moduleProvider });

            this.mOsmv = new MapView(this, 256, mResourceProxy, mProvider);

http://code.google.com/p/osmdroid/issues/detail?id=254

Original comment by jpetti...@gmail.com on 1 Dec 2011 at 11:22

GoogleCodeExporter commented 8 years ago
calling mProvider.clearTileCache() in the onStop seems to be a workaround for 
this issue

@Override
    protected void onStop()
    {
        mProvider.clearTileCache();
        super.onStop();
    }

Original comment by jpetti...@gmail.com on 1 Dec 2011 at 11:35

GoogleCodeExporter commented 8 years ago
See also issue 228.

Original comment by neilboyd on 2 Dec 2011 at 8:12

GoogleCodeExporter commented 8 years ago
comment 3 seems to be doing the trick for me...is there a better solution?

Original comment by christop...@gmail.com on 26 Jun 2012 at 7:10