0
我已經聲明瞭一個三維陣列作爲的Java郎的OutOfMemoryError
double mat[][][] = new mat[400][400][3];
,但我得到的內存錯誤,也許我需要提高我的堆內存。我該怎麼做?
10-21 15:21:43.587 3610-3610/? E/AndroidRuntime: FATAL EXCEPTION: main
10-21 15:21:43.587 3610-3610/? E/AndroidRuntime: Process: com.example.sulabh.phaseonimage, PID: 3610
10-21 15:21:43.587 3610-3610/? E/AndroidRuntime: java.lang.OutOfMemoryError: Failed to allocate a 2572 byte allocation with 952 free bytes and 952B until OOM
10-21 15:21:43.587 3610-3610/? E/AndroidRuntime: at java.lang.reflect.Array.createMultiArray(Native Method)
10-21 15:21:43.587 3610-3610/? E/AndroidRuntime: at java.lang.reflect.Array.newInstance(Array.java:335)
10-21 15:21:43.587 3610-3610/? E/AndroidRuntime: at com.example.sulabh.phaseonimage.MainActivity.reshape2Dcolre(MainActivity.java:743)
10-21 15:21:43.587 3610-3610/? E/AndroidRuntime: at com.example.sulabh.phaseonimage.MainActivity.onActivityResult(MainActivity.java:441)
10-21 15:21:43.587 3610-3610/? E/AndroidRuntime: at android.app.Activity.dispatchActivityResult(Activity.java:6192)
10-21 15:21:43.587 3610-3610/? E/AndroidRuntime: at android.app.ActivityThread.deliverResults(ActivityThread.java:3573)
10-21 15:21:43.587 3610-3610/? E/AndroidRuntime: at android.app.ActivityThread.handleSendResult(ActivityThread.java:3620)
10-21 15:21:43.587 3610-3610/? E/AndroidRuntime: at android.app.ActivityThread.access$1300(ActivityThread.java:151)
10-21 15:21:43.587 3610-3610/? E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1352)
10-21 15:21:43.587 3610-3610/? E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
10-21 15:21:43.587 3610-3610/? E/AndroidRuntime: at android.os.Looper.loop(Looper.java:135)
10-21 15:21:43.587 3610-3610/? E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5257)
10-21 15:21:43.587 3610-3610/? E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
10-21 15:21:43.587 3610-3610/? E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:372)
10-21 15:21:43.587 3610-3610/? E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
10-21 15:21:43.587 3610-3610/? E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
很可能這僅僅是一個較大的症狀內存泄漏。你的應用程序在正常執行時不應該有分配'2572'字節的問題。 – JBirdVegas
你可以在logcat上看到任何「增長堆」行嗎? – Nanoc
首先擺脫多維數組... [爲什麼?](http://stackoverflow.com/questions/15339296/does-order-in-a-declaration-of-multidimensional-array-have-an-influence ),[天真基準](http://ideone.com/cneoAK) – Selvin