andpor / react-native-sqlite-storage

Full featured SQLite3 Native Plugin for React Native (Android and iOS)
MIT License
2.75k stars 521 forks source link

App crashing on big transaction #484

Open EduFrazao opened 3 years ago

EduFrazao commented 3 years ago

Hi. I'm trying run a transaction, that will insert many rows (in this specific case, ~270k rows, on a table with two colmns (numeric, and text with max of 64 charts).

After few seconds after dispatch all querys using tx.executeSQL, the app freezes at physical devices and emulator, and I got many GC Logs until a out of memory crash:

08-14 13:01:10.832 17435 17457 I com.vitruvio: Alloc concurrent copying GC freed 299(22KB) AllocSpace objects, 0(0B) LOS objects, 0% free, 191MB/192MB, paused 34us total 944.451ms
08-14 13:01:10.832 17435 17435 I com.vitruvio: WaitForGcToComplete blocked Alloc on HeapTrim for 1.673s
08-14 13:01:10.832 17435 17435 I com.vitruvio: Starting a blocking GC Alloc
08-14 13:01:10.832 17435 17435 D AndroidRuntime: Shutting down VM
08-14 13:01:10.833 17435 17449 I com.vitruvio: WaitForGcToComplete blocked Background on HeapTrim for 9.508s
08-14 13:01:10.833 17435 17848 I com.vitruvio: WaitForGcToComplete blocked Alloc on HeapTrim for 10.171s
08-14 13:01:10.834 17435 17848 I com.vitruvio: Starting a blocking GC Alloc
08-14 13:01:10.834 17435 17491 I com.vitruvio: Waiting for a blocking GC Alloc
08-14 13:01:10.834 17435 17513 I com.vitruvio: Waiting for a blocking GC Alloc
08-14 13:01:10.834 17435 17451 I com.vitruvio: Waiting for a blocking GC Alloc
08-14 13:01:10.834 17435 17841 I com.vitruvio: Waiting for a blocking GC Alloc
08-14 13:01:10.835 17435 17467 I com.vitruvio: Waiting for a blocking GC Alloc
08-14 13:01:10.835 17435 17496 I com.vitruvio: Waiting for a blocking GC Alloc
08-14 13:00:58.566   846   846 F libc    : crash_dump helper failed to exec
08-14 13:01:10.854 17435 17435 E AndroidRuntime: FATAL EXCEPTION: main
08-14 13:01:10.854 17435 17435 E AndroidRuntime: Process: com.vitruvio, PID: 17435
08-14 13:01:10.854 17435 17435 E AndroidRuntime: java.lang.OutOfMemoryError: OutOfMemoryError thrown while trying to throw an exception; no stack trace available

If I split this job in many transactions (tested transactions of 50k statements), I can complete the work, but without transactional security. Using db.sqlBatch I have the same behavior.

I'm moving from cordova, to react native, and today I have the same workload on Cordova with SQLite, using cordova-sqlite-storage and I can run this big transactions without problems.

In fact, with my cordova application, I run this transaction in about 10 seconds. Spliting in several transactions here, to be able to manage the dataset without crash the application, I was able to run the same job in 70 seconds.

There is any way to improve performance? I'm doing something wrong?

Naua-stack commented 2 years ago

same problem here

EduFrazao commented 2 years ago

same problem here

I've switch to another library. Problem solved.

Naua-stack commented 2 years ago

which library?