Closed GoogleCodeExporter closed 9 years ago
Did some debugging.
When rotating the activitiy is "relaunched".
It means onPause is called on the old activity and a new activity instance is
created
and initialized.
Presumably the old activity is up for garbage collection, unless there are some
pointers that point to it or some subparts (the tile cache).
I don't know a good way to carry over the tile cache between activities.
Original comment by viesturz
on 27 May 2010 at 10:26
I don't think there is a good way to carry over the tile cache, but maybe there
is a
way to call recycle() on the old image tiles when the old activity is no longer
needed.
I know the docs say calling recycle() manually is not needed as it is called
automatically by the garbage collector, but I think the issue here is that more
free
memory is required before the garbage collector has run.
Calling recycle() would clear the used memory manually, immediately freeing the
image
memory, without having to wait for the GC.
Maybe that would already help ?
Original comment by h...@navitell.com
on 27 May 2010 at 10:35
I forgot to mention: I tried forcing a recycle of the image tiles, but I
couldn't
figure out how to remove them from the tile cache. I ended up with the memory
being
recycled, but the overlay still tried to use the tiles on the next screen
redraw,
resulting in gray areas on the map.
What is the proper way of invalidating a tile in the tile cache, so it is
re-read
from memory when needed again ?
Original comment by h...@navitell.com
on 27 May 2010 at 10:38
Probably the view is holding a reference back to the activity that created it.
The context is the usual culprit. Passing
getApplicationContext() instead of "this" for the context parameter often
helps. But this also depends on the activity that's using
the view.
For example, in SampleWithMinimapItemizedoverlay, change
mOsmv = new OpenStreetMapView(this, OpenStreetMapRendererInfo.MAPNIK);
to
mOsmv = new OpenStreetMapView(getApplicationContext(),
OpenStreetMapRendererInfo.MAPNIK);
That's just a suggestion. I haven't looked into this issue.
Original comment by neilboyd
on 27 May 2010 at 10:59
I tried the above suggestion (passing application context in stead of
activity), but
it doesn't seem to help. Still the same out of memory error after about 10
screen
rotations.
Original comment by h...@navitell.com
on 30 May 2010 at 2:15
The Activity.getLastNonConfigurationInstance() method might be what you are
looking for. It allows you to pass claimed resources (e.g. memory,
IO-references) between orientation switches lifecyle event.
Then a relaunched app doesnt need to reload everything.
Original comment by rcgr...@gmail.com
on 13 Jun 2010 at 11:58
Issue 57 has been merged into this issue.
Original comment by neilboyd
on 18 Jun 2010 at 3:13
After rotating the screen over 50 times on my 2.2 Nexus One it was as
responsive as it was at the beginning. And the same on my 1.6 G1.
I think it's time to close this issue.
Original comment by neilboyd
on 7 Jul 2010 at 5:09
Original comment by neilboyd
on 10 Sep 2010 at 2:32
I have the same problem. After a few orientation changes or after pressing back
button and restarting a couple of times the app crashes on HTC Desire. Easily
repeatable.
Original comment by toreleve...@gmail.com
on 20 Jun 2011 at 12:32
I have the same issue. it crashes both on the emulator and on galaxy (1.5)
Original comment by ori.kle...@gmail.com
on 31 Jul 2011 at 2:05
Original issue reported on code.google.com by
neilboyd
on 27 May 2010 at 8:51