Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when trying to export data #120

Closed
jones139 opened this issue Aug 21, 2023 · 9 comments
Closed

Crash when trying to export data #120

jones139 opened this issue Aug 21, 2023 · 9 comments
Assignees
Labels
Milestone

Comments

@jones139
Copy link
Member

Using the data export function to export 12 hours of data resulted in the following crash. It works ok for 2 hours of data.

***** DEVICE INFO
Brand: samsung
Device: j5y17lte
Model: SM-J530F
Manufacturer: samsung
Product: j5y17ltexx
SDK: 28
Release: 9

***** APP INFO
Version: 4.1.10
Installed On: 2022-04-14 16:19:04
Updated On: 2023-07-26 07:56:13
Current Date: 2023-08-21 08:53:57

***** ERROR LOG
java.lang.OutOfMemoryError: Failed to allocate a 150994952 byte allocation with 25165824 free bytes and 61MB until OOM, max allowed footprint 162135992, growth limit 201326592
at java.util.Arrays.copyOf(Arrays.java:3260)
at java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:125)
at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:660)
at java.lang.StringBuilder.append(StringBuilder.java:203)
at org.json.JSONStringer.string(JSONStringer.java:344)
at org.json.JSONStringer.value(JSONStringer.java:252)
at org.json.JSONObject.writeTo(JSONObject.java:723)
at org.json.JSONStringer.value(JSONStringer.java:237)
at org.json.JSONArray.writeTo(JSONArray.java:613)
at org.json.JSONArray.toString(JSONArray.java:585)
at uk.org.openseizuredetector.LogManager.cursor2Json(LogManager.java:220)
at uk.org.openseizuredetector.LogManager.lambda$getDatapointsByDate$0$uk-org-openseizuredetector-LogManager(LogManager.java:473)
at uk.org.openseizuredetector.LogManager$$ExternalSyntheticLambda5.accept(Unknown Source:4)
at uk.org.openseizuredetector.LogManager$SelectQueryTask.onPostExecute(LogManager.java:754)
at uk.org.openseizuredetector.LogManager$SelectQueryTask.onPostExecute(LogManager.java:701)
at android.os.AsyncTask.finish(AsyncTask.java:695)
at android.os.AsyncTask.access$600(AsyncTask.java:180)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:712)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:216)
at android.app.ActivityThread.main(ActivityThread.java:7266)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)

@jones139
Copy link
Member Author

The export data function is extremely slow and it looks like it is eating loads of memory - there must be a better way to do it. The relevant code is here: https://github.com/OpenSeizureDetector/Android_Pebble_SD/blob/master/app/src/main/java/uk/org/openseizuredetector/ExportDataActivity.java#L268
There is definitely an issue with running this on the UI thread, but moving it to a separate thread will not solve the memory consumption problem....

I think the thing to do is not use LogManager. cursor2json but instead receive the cursor and write the csv file directly to avoid the overhead of turning it into json and parsing back?

@jones139 jones139 added this to the V4.1.11 milestone Aug 21, 2023
@jones139 jones139 self-assigned this Aug 21, 2023
@jones139 jones139 added the bug label Aug 21, 2023
@jones139
Copy link
Member Author

This is quite a serious bug as it prevents users obtaining their data easily, so I'll do a quick fix as V4.1.11 rather than waiting for V4.2.

@AroonPro
Copy link

AroonPro commented Aug 21, 2023 via email

@jones139
Copy link
Member Author

jones139 commented Aug 21, 2023 via email

@jones139
Copy link
Member Author

a4b6a43 should fix the out of memory crash - we only process the data one row at a time rather than all at once.
It is still a bit slow so you get some "app not responding" prompts which will need fixing in the future, but it works as long as you press 'wait', so closing this issue.

@AroonPro
Copy link

AroonPro commented Aug 22, 2023 via email

@AroonPro
Copy link

AroonPro commented Aug 22, 2023 via email

@jones139
Copy link
Member Author

jones139 commented Aug 22, 2023 via email

@AroonPro
Copy link

AroonPro commented Aug 22, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants