同様のトピックを検索しましたが、EDF ファイルとメモリ不足エラーに関連するものは見つかりませんでした。
だから、ここに私の問題が あります.ファイルを参照し、「.edf」ファイルを選択して解析するAndroidスタジオでAndroidアプリを開発しています。ただし、一部のファイルでは、次のエラーがスローされます (スタックトレースを使用):
I/xample.styleap: Starting a blocking GC Alloc
Starting a blocking GC Alloc
I/xample.styleap: Alloc concurrent copying GC freed 15804(1107KB) AllocSpace objects, 5(108KB) LOS objects, 86% free, 1955KB/13MB, paused 148us total 44.577ms
Starting a blocking GC Alloc
I/xample.styleap: Alloc young concurrent copying GC freed 0(15KB) AllocSpace objects, 0(0B) LOS objects, 86% free, 1955KB/13MB, paused 120us total 16.603ms
Starting a blocking GC Alloc
I/xample.styleap: Alloc concurrent copying GC freed 2019(110KB) AllocSpace objects, 0(0B) LOS objects, 86% free, 1844KB/13MB, paused 83us total 25.049ms
Forcing collection of SoftReferences for 488MB allocation
Starting a blocking GC Alloc
I/xample.styleap: Alloc concurrent copying GC freed 2053(69KB) AllocSpace objects, 0(0B) LOS objects, 87% free, 1790KB/13MB, paused 75us total 22.140ms
W/xample.styleap: Throwing OutOfMemoryError "Failed to allocate a 512000012 byte allocation with 12582912 free bytes and 190MB until OOM, target footprint 14416192, growth limit 201326592" (VmSize 1212600 kB)
I/xample.styleap: Starting a blocking GC Alloc
Starting a blocking GC Alloc
I/xample.styleap: Alloc young concurrent copying GC freed 4(31KB) AllocSpace objects, 0(0B) LOS objects, 87% free, 1774KB/13MB, paused 79us total 15.057ms
I/xample.styleap: Starting a blocking GC Alloc
I/xample.styleap: Alloc concurrent copying GC freed 3(16KB) AllocSpace objects, 0(0B) LOS objects, 87% free, 1774KB/13MB, paused 83us total 23.495ms
Forcing collection of SoftReferences for 488MB allocation
Starting a blocking GC Alloc
I/xample.styleap: Alloc concurrent copying GC freed 50(17KB) AllocSpace objects, 0(0B) LOS objects, 87% free, 1788KB/13MB, paused 73us total 22.532ms
W/xample.styleap: Throwing OutOfMemoryError "Failed to allocate a 512000016 byte allocation with 12582912 free bytes and 190MB until OOM, target footprint 14414784, growth limit 201326592" (VmSize 1212600 kB)
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.styleapp, PID: 30041
java.lang.OutOfMemoryError: Failed to allocate a 512000016 byte allocation with 12582912 free bytes and 190MB until OOM, target footprint 14414784, growth limit 201326592
at br.unb.biologiaanimal.edf.EDFReader.readRecords(EDFReader.java:106)
at br.unb.biologiaanimal.edf.EDFReader.<init>(EDFReader.java:25)
at br.unb.biologiaanimal.edf.EDF.<init>(EDF.java:24)
at com.example.styleapp.MainActivity.runEDFfile(MainActivity.java:100)
at com.example.styleapp.MainActivity.access$000(MainActivity.java:24)
at com.example.styleapp.MainActivity$2.onMenuItemClick(MainActivity.java:82)
at androidx.appcompat.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:154)
at androidx.appcompat.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:991)
at androidx.appcompat.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:981)
at androidx.appcompat.widget.ActionMenuView.invokeItem(ActionMenuView.java:625)
at androidx.appcompat.view.menu.ActionMenuItemView.onClick(ActionMenuItemView.java:151)
at android.view.View.performClick(View.java:7140)
at android.view.View.performClickInternal(View.java:7117)
at android.view.View.access$3500(View.java:801)
at android.view.View$PerformClick.run(View.java:27355)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7410)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:935)
W/System: A resource failed to call close.
Java用のEDFパーサーライブラリを使用しています: https://github.com/lab-neuro-comp/EDF
私のソースコード (MainActivity.java):
import br.unb.biologiaanimal.edf.EDF;
EDF edf = new EDF(filepath);
EDF コンストラクターが特定のファイルパスで呼び出されている間は失敗します。多くの場所で、JVM/Android の VM 不足やヒープ サイズが原因で失敗すると言われています。しかし、私もそれを大事にしたと思います:
studio.vmoptions 内
-Xmx2048m
これは、Android Studio の JVM VM サイズを指定していると思います。Java 仮想マシンが使用しようとするメモリの最大量も出力しています。
Runtime rt = Runtime.getRuntime();
long maxMemory = rt.maxMemory();
これは印刷します
201326592
つまり、約 201MB が利用可能です。
では、4.2MB の EDF ファイルを正常にロードしたときに 1.9MB の EDF ファイルをロード中に失敗する (メモリ不足になる) 理由は何ですか?