Android build, ошибка OutOfMemoryException
Tarasus opened this issue · 1 comments
Собрал под Android, при вызове функции lookupForMeanings() из документации, в Logcat возвращается гора текста и потом всё заканчивается OutOfMemoryException.
Логи прилагаю.
2023-01-30 12:56:42.654 E: onCreate: START
2023-01-30 12:56:43.029 E: lemma_test_func: lookupForMeanings
2023-01-30 12:56:45.630 I: Background concurrent copying GC freed 272187(6MB) AllocSpace objects, 0(0B) LOS objects, 28% free, 61MB/85MB, paused 192us total 186.398ms
2023-01-30 12:56:46.573 I: Background concurrent copying GC freed 671079(16MB) AllocSpace objects, 0(0B) LOS objects, 23% free, 79MB/103MB, paused 162us total 342.056ms
2023-01-30 12:56:47.315 I: Waiting for a blocking GC ProfileSaver
2023-01-30 12:56:47.660 I: Background concurrent copying GC freed 775479(19MB) AllocSpace objects, 0(0B) LOS objects, 19% free, 99MB/123MB, paused 171us total 484.283ms
2023-01-30 12:56:47.660 I: WaitForGcToComplete blocked ProfileSaver on ClassLinker for 344.448ms
2023-01-30 12:56:48.900 I: Background concurrent copying GC freed 881656(22MB) AllocSpace objects, 0(0B) LOS objects, 16% free, 121MB/145MB, paused 168us total 634.989ms
2023-01-30 12:56:50.310 I: Background concurrent copying GC freed 962892(25MB) AllocSpace objects, 0(0B) LOS objects, 14% free, 146MB/170MB, paused 204us total 802.777ms
2023-01-30 12:56:51.571 I: Waiting for a blocking GC Alloc
2023-01-30 12:56:51.958 I: Background concurrent copying GC freed 1067639(28MB) AllocSpace objects, 0(0B) LOS objects, 12% free, 163MB/187MB, paused 207us total 1.025s
2023-01-30 12:56:51.958 I: WaitForGcToComplete blocked Alloc on HeapTrim for 387.145ms
2023-01-30 12:56:51.958 I: Starting a blocking GC Alloc
2023-01-30 12:56:52.701 I: Waiting for a blocking GC Alloc
2023-01-30 12:56:53.705 I: Background concurrent copying GC freed 1002834(25MB) AllocSpace objects, 0(0B) LOS objects, 12% free, 166MB/190MB, paused 175us total 1.142s
2023-01-30 12:56:53.705 I: WaitForGcToComplete blocked Alloc on HeapTrim for 1.003s
2023-01-30 12:56:53.705 I: Starting a blocking GC Alloc
2023-01-30 12:56:54.087 I: Starting a blocking GC Alloc
2023-01-30 12:56:54.087 I: Starting a blocking GC Alloc
2023-01-30 12:56:55.272 I: Alloc concurrent copying GC freed 444656(11MB) AllocSpace objects, 1(35MB) LOS objects, 15% free, 134MB/158MB, paused 235us total 1.184s
2023-01-30 12:56:56.371 I: Clamp target GC heap from 197MB to 192MB
2023-01-30 12:56:56.371 I: Background concurrent copying GC freed 0(15KB) AllocSpace objects, 0(0B) LOS objects, 9% free, 173MB/192MB, paused 193us total 1.098s
2023-01-30 12:56:59.518 I: Waiting for a blocking GC Alloc
2023-01-30 12:57:00.709 I: Clamp target GC heap from 215MB to 192MB
2023-01-30 12:57:00.709 I: Background concurrent copying GC freed 9(43KB) AllocSpace objects, 0(0B) LOS objects, 0% free, 191MB/192MB, paused 179us total 1.193s
2023-01-30 12:57:00.709 I: WaitForGcToComplete blocked Alloc on HeapTrim for 1.191s
2023-01-30 12:57:00.709 I: Starting a blocking GC Alloc
2023-01-30 12:57:00.710 I: Waiting for a blocking GC Alloc
2023-01-30 12:57:01.860 I: Clamp target GC heap from 215MB to 192MB
2023-01-30 12:57:01.861 I: Background concurrent copying GC freed 0(0B) AllocSpace objects, 0(0B) LOS objects, 0% free, 191MB/192MB, paused 200us total 1.151s
2023-01-30 12:57:01.861 I: WaitForGcToComplete blocked Alloc on HeapTrim for 1.150s
2023-01-30 12:57:01.861 I: Starting a blocking GC Alloc
2023-01-30 12:57:01.861 I: Starting a blocking GC Alloc
2023-01-30 12:57:01.861 I: Waiting for a blocking GC Alloc
2023-01-30 12:57:03.012 I: Clamp target GC heap from 215MB to 192MB
2023-01-30 12:57:03.012 I: Alloc concurrent copying GC freed 1(8B) AllocSpace objects, 0(0B) LOS objects, 0% free, 191MB/192MB, paused 160us total 1.150s
2023-01-30 12:57:03.012 I: Starting a blocking GC Alloc
2023-01-30 12:57:03.012 I: Waiting for a blocking GC Alloc
2023-01-30 12:57:04.166 I: Clamp target GC heap from 215MB to 192MB
2023-01-30 12:57:04.166 I: Alloc concurrent copying GC freed 0(0B) AllocSpace objects, 0(0B) LOS objects, 0% free, 191MB/192MB, paused 165us total 1.153s
2023-01-30 12:57:04.166 I: Forcing collection of SoftReferences for 368B allocation
2023-01-30 12:57:04.166 I: Starting a blocking GC Alloc
2023-01-30 12:57:04.166 I: Waiting for a blocking GC Alloc
2023-01-30 12:57:06.001 I: Clamp target GC heap from 215MB to 192MB
2023-01-30 12:57:06.001 I: Alloc concurrent copying GC freed 279(20KB) AllocSpace objects, 0(0B) LOS objects, 0% free, 191MB/192MB, paused 155us total 1.835s
2023-01-30 12:57:06.002 I: WaitForGcToComplete blocked Background on HeapTrim for 4.140s
2023-01-30 12:57:06.002 I: Waiting for a blocking GC Alloc
2023-01-30 12:57:06.009 I: Waiting for a blocking GC Alloc
2023-01-30 12:57:07.153 I: Clamp target GC heap from 215MB to 192MB
2023-01-30 12:57:07.153 I: Background concurrent copying GC freed 0(0B) AllocSpace objects, 0(0B) LOS objects, 0% free, 191MB/192MB, paused 227us total 1.151s
2023-01-30 12:57:07.153 I: WaitForGcToComplete blocked Alloc on HeapTrim for 1.151s
2023-01-30 12:57:07.153 I: Starting a blocking GC Alloc
2023-01-30 12:57:07.153 I: Starting a blocking GC Alloc
2023-01-30 12:57:07.153 I: Waiting for a blocking GC Alloc
2023-01-30 12:57:08.305 I: Clamp target GC heap from 215MB to 192MB
2023-01-30 12:57:08.305 I: Alloc concurrent copying GC freed 0(0B) AllocSpace objects, 0(0B) LOS objects, 0% free, 191MB/192MB, paused 168us total 1.151s
2023-01-30 12:57:08.305 I: Starting a blocking GC Alloc
2023-01-30 12:57:08.305 I: Waiting for a blocking GC Alloc
2023-01-30 12:57:09.456 I: Clamp target GC heap from 215MB to 192MB
2023-01-30 12:57:09.456 I: Alloc concurrent copying GC freed 0(0B) AllocSpace objects, 0(0B) LOS objects, 0% free, 191MB/192MB, paused 167us total 1.151s
2023-01-30 12:57:09.457 I: Forcing collection of SoftReferences for 304B allocation
2023-01-30 12:57:09.457 I: Starting a blocking GC Alloc
2023-01-30 12:57:09.457 I: Waiting for a blocking GC Alloc
2023-01-30 12:57:11.267 I: Clamp target GC heap from 215MB to 192MB
2023-01-30 12:57:11.267 I: Alloc concurrent copying GC freed 0(0B) AllocSpace objects, 0(0B) LOS objects, 0% free, 191MB/192MB, paused 247us total 1.809s
2023-01-30 12:57:11.267 I: WaitForGcToComplete blocked Alloc on HeapTrim for 9.405s
2023-01-30 12:57:11.267 I: Starting a blocking GC Alloc
2023-01-30 12:57:11.267 W: Throwing OutOfMemoryError "Failed to allocate a 304 byte allocation with 136 free bytes and 136B until OOM, max allowed footprint 201326592, growth limit 201326592" (VmSize 1158244 kB)
2023-01-30 12:57:11.267 I: Waiting for a blocking GC Alloc
2023-01-30 12:57:12.426 I: Clamp target GC heap from 215MB to 192MB
2023-01-30 12:57:12.426 I: Background concurrent copying GC freed 0(0B) AllocSpace objects, 0(0B) LOS objects, 0% free, 191MB/192MB, paused 175us total 1.159s
2023-01-30 12:57:12.427 I: WaitForGcToComplete blocked Alloc on HeapTrim for 1.159s
2023-01-30 12:57:12.427 I: Starting a blocking GC Alloc
2023-01-30 12:57:12.427 I: Starting a blocking GC Alloc
2023-01-30 12:57:12.427 I: Waiting for a blocking GC Alloc
2023-01-30 12:57:13.581 I: Clamp target GC heap from 215MB to 192MB
2023-01-30 12:57:13.581 I: Alloc concurrent copying GC freed 0(0B) AllocSpace objects, 0(0B) LOS objects, 0% free, 191MB/192MB, paused 169us total 1.154s
2023-01-30 12:57:13.581 I: Starting a blocking GC Alloc
2023-01-30 12:57:13.581 I: Waiting for a blocking GC Alloc
2023-01-30 12:57:14.734 I: Clamp target GC heap from 215MB to 192MB
2023-01-30 12:57:14.734 I: Alloc concurrent copying GC freed 0(0B) AllocSpace objects, 0(0B) LOS objects, 0% free, 191MB/192MB, paused 228us total 1.153s
2023-01-30 12:57:14.734 I: Forcing collection of SoftReferences for 152B allocation
2023-01-30 12:57:14.735 I: Starting a blocking GC Alloc
2023-01-30 12:57:14.735 I: Waiting for a blocking GC Alloc
2023-01-30 12:57:16.542 I: Clamp target GC heap from 215MB to 192MB
2023-01-30 12:57:16.542 I: Alloc concurrent copying GC freed 3(72B) AllocSpace objects, 0(0B) LOS objects, 0% free, 191MB/192MB, paused 155us total 1.807s
2023-01-30 12:57:16.542 I: WaitForGcToComplete blocked Alloc on HeapTrim for 4.115s
2023-01-30 12:57:16.542 I: Starting a blocking GC Alloc
2023-01-30 12:57:16.542 I: WaitForGcToComplete blocked HeapTrim on HeapTrim for 4.115s
2023-01-30 12:57:16.543 W: Throwing OutOfMemoryError "Failed to allocate a 152 byte allocation with 96 free bytes and 96B until OOM, max allowed footprint 201326592, growth limit 201326592" (VmSize 1158244 kB, recursive case)
2023-01-30 12:57:16.543 W: "main" prio=5 tid=1 Runnable
2023-01-30 12:57:16.543 W: | group="main" sCount=0 dsCount=0 flags=0 obj=0x74922f68 self=0xec7f0000
2023-01-30 12:57:16.543 W: | sysTid=24155 nice=-10 cgrp=default sched=0/0 handle=0xf0e9f4a8
2023-01-30 12:57:16.543 W: | state=R schedstat=( 0 0 0 ) utm=2683 stm=196 core=4 HZ=100
2023-01-30 12:57:16.543 W: | stack=0xff700000-0xff702000 stackSize=8MB
2023-01-30 12:57:16.543 W: | held mutexes= "mutator lock"(shared held)
2023-01-30 12:57:16.543 W: at com.github.demidko.aot.AotReader.readLemmas(AotReader.java:52)
2023-01-30 12:57:16.543 W: at com.github.demidko.aot.WordformMeaning.(WordformMeaning.java:51)
2023-01-30 12:57:16.543 W: at com.github.demidko.aot.WordformMeaning.lookupForMeanings(WordformMeaning.java:93)
2023-01-30 12:57:16.543 W: at tarasus.aot.test.MainActivity.lemma_test_func(MainActivity.java:41)
2023-01-30 12:57:16.543 W: at tarasus.aot.test.MainActivity.onCreate(MainActivity.java:26)
2023-01-30 12:57:16.543 W: at android.app.Activity.performCreate(Activity.java:7335)
2023-01-30 12:57:16.543 W: at android.app.Activity.performCreate(Activity.java:7326)
2023-01-30 12:57:16.543 W: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1275)
2023-01-30 12:57:16.543 W: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3119)
2023-01-30 12:57:16.543 W: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3282)
2023-01-30 12:57:16.543 W: at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
2023-01-30 12:57:16.543 W: at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
2023-01-30 12:57:16.543 W: at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
2023-01-30 12:57:16.543 W: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1970)
2023-01-30 12:57:16.543 W: at android.os.Handler.dispatchMessage(Handler.java:106)
2023-01-30 12:57:16.543 W: at android.os.Looper.loop(Looper.java:214)
2023-01-30 12:57:16.543 W: at android.app.ActivityThread.main(ActivityThread.java:7156)
2023-01-30 12:57:16.543 W: at java.lang.reflect.Method.invoke(Native method)
2023-01-30 12:57:16.543 W: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
2023-01-30 12:57:16.543 W: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)
2023-01-30 12:57:16.544 I: Waiting for a blocking GC Alloc
2023-01-30 12:57:17.663 I: Background concurrent copying GC freed 81086(18MB) AllocSpace objects, 1(38MB) LOS objects, 15% free, 134MB/158MB, paused 200us total 1.120s
2023-01-30 12:57:17.663 I: WaitForGcToComplete blocked Alloc on HeapTrim for 1.119s
2023-01-30 12:57:17.663 I: Starting a blocking GC Alloc
2023-01-30 12:57:17.664 D: Shutting down VM
2023-01-30 12:57:17.665 E: FATAL EXCEPTION: main
Process: tarasus.aot.test, PID: 24155
java.lang.OutOfMemoryError: OutOfMemoryError thrown while trying to throw OutOfMemoryError; no stack trace available
2023-01-30 12:57:17.687 I: Sending signal. PID: 24155 SIG: 9
Библиотека задумывалась для классического бекенда (jvm). Запустить под Android, это конечно сильно 🙂
Ошибка достаточно исчерпывающая: на вашем устройстве недостаточно памяти. Запускайте под более мощным устройством, или на бекенде. Словарь русского языка в кешируется в куче для быстрого доступа. Это занимает от одного до двух гигабайт в тестах.