HttpClient.execute throwing OutOfMemoryError

前端 未结 3 1248
醉话见心
醉话见心 2021-02-14 00:42

I\'ve an Android application that posting JSONObject as a entity by using ByteArrayEntity object. Here how it looks like:

post.setEntit         


        
3条回答
  •  耶瑟儿~
    2021-02-14 01:13

    Android devices have a per-process memory limit. The default default is 24MB, but some devices have a lower value, eg 16MB or perhaps lower. The X10i appears to have 384MB RAM, which is low for a modern Android device (1GB is now standard), and this may place additional constraints.

    I would suggest:

    1. First check the per-process limit on your device. Use ActivityManager.getMemoryClass() to check.
    2. Look at your actual memory usage using DDMS.

    You may find that, just before you are making this call, you are already at the upper limit of memory; the initialisation of the HTTPClient and the call might take you just over the limit. This will be more likely if the OOM occurs on the first call.

    If this happens only sporadically, or after a number of calls, you might have a memory leak. DDMS will help you track that down using the get allocations feature.

提交回复
热议问题