SQL Lite DB not always closed in OpenStreetMapTileFilesystemProvider - possible leak

Bug #579429 reported by Guillaume Rosaire
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenSatNav
Fix Released
Medium
Murphy

Bug Description

When changing orientation, LogCat shows that there is an issue with the sqllite db not released when garbage collected. We should ensure that it is well closed.

E/Database( 6238): Leak found
E/Database( 6238): java.lang.IllegalStateException: /data/data/org.opensatnav/databases/osmaptilefscache_db SQLiteDatabase created and never closed
E/Database( 6238): at android.database.sqlite.SQLiteDatabase.<init>(SQLiteDatabase.java:1581)
E/Database( 6238): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:638)
E/Database( 6238): at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:659)
E/Database( 6238): at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:652)
E/Database( 6238): at android.app.ApplicationContext.openOrCreateDatabase(ApplicationContext.java:463)
E/Database( 6238): at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:181)
E/Database( 6238): at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:98)
E/Database( 6238): at org.andnav.osm.views.util.OpenStreetMapTileFilesystemProvider$OpenStreetMapTileFilesystemProviderDataBase.<init>(OpenStreetMapTileFilesystemProvider.java:282)
E/Database( 6238): at org.andnav.osm.views.util.OpenStreetMapTileFilesystemProvider.<init>(OpenStreetMapTileFilesystemProvider.java:99)
E/Database( 6238): at org.andnav.osm.views.util.OpenStreetMapTileProvider.<init>(OpenStreetMapTileProvider.java:68)
E/Database( 6238): at org.andnav.osm.views.OpenStreetMapView.<init>(OpenStreetMapView.java:111)
E/Database( 6238): at org.opensatnav.SatNavActivity.onCreate(SatNavActivity.java:102)
E/Database( 6238): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
E/Database( 6238): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2243)
E/Database( 6238): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2296)
E/Database( 6238): at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3290)
E/Database( 6238): at android.app.ActivityThread.access$1900(ActivityThread.java:112)
E/Database( 6238): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1708)
E/Database( 6238): at android.os.Handler.dispatchMessage(Handler.java:99)
E/Database( 6238): at android.os.Looper.loop(Looper.java:123)
E/Database( 6238): at android.app.ActivityThread.main(ActivityThread.java:3960)
E/Database( 6238): at java.lang.reflect.Method.invokeNative(Native Method)
E/Database( 6238): at java.lang.reflect.Method.invoke(Method.java:521)
E/Database( 6238): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
E/Database( 6238): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
E/Database( 6238): at dalvik.system.NativeStart.main(Native Method)
@

Revision history for this message
Guillaume Rosaire (zerog) wrote :

I tried with a recent andnav2 version and it doesn't have this issue. There must be a difference with our way of using the OpenStreetMapTileFilesystemProvider instance, and especially its database connection.

Revision history for this message
chris_debian (cjhandrew) wrote :

Pushed-back. Needs re-assessing in line with other issues after 0.9 release.

Chris.

Revision history for this message
Murphy (murphy2712+launchpad) wrote :

I created a patch to close the "osmaptilefscache_db" database with the onDestroy() of OpenSatNavActivity since the finalize() function is not reliable:
http://developer.android.com/reference/android/app/Activity.html#finalize()

Revision history for this message
chris_debian (cjhandrew) wrote :

Nice work, Murphy!

Chris.

Revision history for this message
Murphy (murphy2712+launchpad) wrote :

Since the patch is integrated and I can't reproduce the bug anymore (and nobody's complaining) I think this issue is closed :)

Changed in opensatnav:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.