0

The app is pretty basic, it allows the users to fill out the surveys and then it sends them to the server. I have setPersistence enabled so it will also work while they are offline and it just sends them to the server when online.

This works fine, however after a certain number of surveys (30-50) the app crashes each time on start with com.google.android.gms.dynamite_dynamitemodulesc error. All of them are reported as different errors due to memory address in the name. The explanation for the error is

Caused by java.lang.OutOfMemoryError Failed to allocate a 202 byte allocation with 15532496 free bytes and 14MB until OOM; failed due to fragmentation (required continguous free 16384 bytes for a new buffer where largest contiguous free 12288 bytes)

The issue is that after the surveys are sent, they are not removed from local memory for some reason. So even though the app is fully in sync and nothing is accessed locally, the cache isn't cleared.

I was looking for a way to manually clear the Firebase cache, but as far as I see it's not possible.

Here is how the data is stored at the end of the session (pretty basic). I'd like to point out again that this data isn't accessed after this is done, which is why I figured it should clear the cache once it syncs it with the server.

DatabaseReference session = mResults.push();

session.child("examiner").setValue(username);
session.child("place").setValue(place);
session.child("filled_by").setValue(fillingOut);
session.child("timestamp").setValue(millis);
session.child("ref_number").setValue(referenceCode);

DatabaseReference questions = session.child("questions");

for(Question q : allQuestions) {

    DatabaseReference question = questions.push();

    question.child("question").setValue(q.text);
    question.child("skipped").setValue(q.skipped);
    DatabaseReference answers = question.child("answers");

    for(Answer a : q.answers) {

        DatabaseReference answer = answers.push();

        answer.child("selected").setValue(a.selected);
        answer.child("text").setValue(a.text);
        answer.child("value").setValue(a.inputValue);
    }
}
Stefan Salatic
  • 4,513
  • 3
  • 22
  • 30
  • did u try this?https://stackoverflow.com/a/32245018/9025311 –  May 13 '18 at 14:49
  • Yes, before that the limit was around 20ish. This just delayed the issue and allowed a bit more surveys before giving the same error. – Stefan Salatic May 13 '18 at 14:54
  • I think your problem is the `cashe not cleared` so do you mind adding `yourquery.keepSynced(true);` so that it will not be evicted from the persistent disk cache. –  May 13 '18 at 17:18
  • Have you removed the listeners? – Alex Mamo May 14 '18 at 08:05
  • I don't have the listeners for this data (I do have for some ID's, but these are a thousand times smaller than a single survey). I'd like to add that the issue is with persistence. Usually only one survey is completed per app session and the app is restarted in the meantime so all reference to this data is lost in the meantime – Stefan Salatic May 14 '18 at 08:22

0 Answers0