Skip to content

Commit

Permalink
Merge pull request #737 from mixpanel/prevent-out-of-memory-crash
Browse files Browse the repository at this point in the history
Prevent the out of memory crash when adding event to the SQLiteDatabase
  • Loading branch information
zihejia authored Apr 29, 2021
2 parents f90201a + 975f854 commit ae1ae19
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions BUILDING.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ inside of its src/main directory. To include the library in your ant or Eclipse
project, add the following library reference to your project's project.properties file:

android.library.reference.1=RELATIVE_PATH_TO_THE_MIXPANEL_DIRECTORY/src/main

Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ public int addJSON(JSONObject j, String token, Table table, boolean isAutomaticR
c.moveToFirst();
count = c.getInt(0);
} catch (final SQLiteException e) {
MPLog.e(LOGTAG, "Could not add Mixpanel data to table " + tableName + ". Re-initializing database.", e);
MPLog.e(LOGTAG, "Could not add Mixpanel data to table");

// We assume that in general, the results of a SQL exception are
// unrecoverable, and could be associated with an oversized or
Expand All @@ -340,6 +340,8 @@ public int addJSON(JSONObject j, String token, Table table, boolean isAutomaticR
c = null;
}
mDb.deleteDatabase();
} catch (final OutOfMemoryError e) {
MPLog.e(LOGTAG, "Out of memory when adding Mixpanel data to table");
} finally {
if (c != null) {
c.close();
Expand Down

0 comments on commit ae1ae19

Please sign in to comment.