sematext/sematext-logsene-android

Investigate potential memory leaks

otisg opened this issue · 3 comments

otisg commented

From a user:

On the memory leak, it seems the issue was more Android-related.

We only made three changes overall:

  • Closing cursors after accessing the SQLite Database
  • ObjectDBHelper changed to static
  • Updated the okhttp dependency version

The issues were probably being caused by okhttp, but to be safe we made the aforementioned changes.

otisg commented

From the same user:

SqliteObjectQueue.java:

  1. changed ObjectDbHelper to static
    public static class ObjectDbHelper extends SQLiteOpenHelper {

  2. closed cursor on - public List peek(int max){
    ...
    c.close();
    return results;
    }

on build.gradle:
3. Changed okhttp version:

implementation 'com.squareup.okhttp3:okhttp:4.3.0'

(it worked for sematext but broke another part of our app, so we are currently testing with 3.12)

gr0 commented

The changes are now in master. I will release a new version of the library with them. The things that needed to be done is refactoring of the SQLLite usage, cursor closing and statements closing. After that profiling show that the memory usage is stable and no more leaks are reported.

gr0 commented

The commit that fixes the issue is: 0b59695