close

本教學示範如何解決Android API 16 (4.1.2) 模擬器的 Failed to allocate memory 錯誤。

最近筆者將Android API升級到16,並嘗試在平板電腦的模擬器上運行程序。可是,如果將螢幕解析度設置在WXGA720、WXGA800或者WXGA800-7in,運行程序時總是出現下面的錯誤提示︰

Failed to allocate memory: 8

This application has requested the Runtime to terminate it in an unusual way.

Please contact the application's support team for more information.

筆者查看了不少的內容,大部份都是指出錯誤是由於記憶體不足的問題所致。可是筆者使用裝有32GB記憶體的機器仍然出現錯誤。修改模擬器並指定512MB、256MB或者128MB也不能解決錯誤問題。

經過多小時的嘗試,使用command開啟模擬器卻沒有錯誤的問題。由此可見,使用command即可解決記憶體不足的錯誤問題。

解法方法如下:
1.在Project上點擊滑鼠右鍵,在「Run As」內選擇「Run Configurations…」。
2.在「Target」內的「Additional Emulator Command Line Options」輸入︰-memory 512
強行將模擬器的記憶體設定為512MB。之後按下「Apply」,然後再按「Run」執行Android程序。
3.等待一會兒,就會看到Android模擬器。

Source:http://www.foolegg.com/how-to-solve-the-problem-of-failed-to-allocate-memory-in-android-api-16-emulator/

arrow
arrow
    全站熱搜

    chungweis 發表在 痞客邦 留言(0) 人氣()