OutOfMemoryError开始排球RequestQueue

时间:2014-05-12 23:32:32

标签: android out-of-memory android-volley

我正在为我的应用程序使用片段和凌空但是当我尝试初始化凌空RequestQueue我的应用程序崩溃并抛出OutOfMemoryError时,它正在尝试将1.8 GB的数据初始化到内存中

    05-12 18:00:51.947  10765-10781/com.sellcom.tracker W/dalvikvm﹕ 1802465107 byte    allocation exceeds the 67108864 byte maximum heap size
    05-12 18:00:51.947  10765-10781/com.sellcom.tracker I/dalvikvm-heap﹕ Forcing collection of SoftReferences for 1802465107-byte allocation
    05-12 18:00:51.981  10765-10781/com.sellcom.tracker D/dalvikvm﹕ GC_BEFORE_OOM freed 330K, 6% free 8660K/9207K, paused 34ms, total 34ms
    05-12 18:00:51.982  10765-10781/com.sellcom.tracker E/dalvikvm-heap﹕ Out of memory on a 1802465107-byte allocation.
    05-12 18:00:51.982  10765-10781/com.sellcom.tracker I/dalvikvm﹕ "Thread-1108" prio=5 tid=11 RUNNABLE
    05-12 18:00:51.982  10765-10781/com.sellcom.tracker I/dalvikvm﹕ | group="main" sCount=0 dsCount=0 obj=0x41718598 self=0x51363d10
    05-12 18:00:51.982  10765-10781/com.sellcom.tracker I/dalvikvm﹕ | sysTid=10781 nice=10 sched=0/0 cgrp=apps/bg_non_interactive handle=1362874264
    05-12 18:00:51.982  10765-10781/com.sellcom.tracker I/dalvikvm﹕ | schedstat=( 43264540 285215383 80 ) utm=4 stm=0 core=1
    05-12 18:00:51.982  10765-10781/com.sellcom.tracker I/dalvikvm﹕ at com.android.volley.toolbox.DiskBasedCache.streamToBytes(DiskBasedCache.java:~316)
    05-12 18:00:51.982  10765-10781/com.sellcom.tracker I/dalvikvm﹕ at com.android.volley.toolbox.DiskBasedCache.readString(DiskBasedCache.java:526)
    05-12 18:00:51.982  10765-10781/com.sellcom.tracker I/dalvikvm﹕ at com.android.volley.toolbox.DiskBasedCache.readStringStringMap(DiskBasedCache.java:548)
    05-12 18:00:51.982  10765-10781/com.sellcom.tracker I/dalvikvm﹕ at com.android.volley.toolbox.DiskBasedCache$CacheHeader.readHeader(DiskBasedCache.java:392)
    05-12 18:00:51.983  10765-10781/com.sellcom.tracker I/dalvikvm﹕ at com.android.volley.toolbox.DiskBasedCache.initialize(DiskBasedCache.java:155)
    05-12 18:00:51.983  10765-10781/com.sellcom.tracker I/dalvikvm﹕ at com.android.volley.CacheDispatcher.run(CacheDispatcher.java:84)
    05-12 18:00:51.983  10765-10781/com.sellcom.tracker I/dalvikvm﹕ [ 05-12 18:00:51.984 10765:0x2a1d D/dalvikvm ]
threadid=11: exiting
    05-12 18:00:51.984  10765-10781/com.sellcom.tracker W/dalvikvm﹕ threadid=11: thread exiting with uncaught exception (group=0x40e51908)
    05-12 18:00:51.986  10765-10781/com.sellcom.tracker E/AndroidRuntime﹕ FATAL EXCEPTION: Thread-1108
java.lang.OutOfMemoryError
        at com.android.volley.toolbox.DiskBasedCache.streamToBytes(DiskBasedCache.java:316)
        at com.android.volley.toolbox.DiskBasedCache.readString(DiskBasedCache.java:526)
        at com.android.volley.toolbox.DiskBasedCache.readStringStringMap(DiskBasedCache.java:548)
        at com.android.volley.toolbox.DiskBasedCache$CacheHeader.readHeader(DiskBasedCache.java:392)
        at com.android.volley.toolbox.DiskBasedCache.initialize(DiskBasedCache.java:155)
        at com.android.volley.CacheDispatcher.run(CacheDispatcher.java:84)

我减少了我的片段实现,以显示崩溃发生的位置:

public class FragmentWeather extends Fragment{

RequestQueue queue;

    @Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    queue = Volley.newRequestQueue(getActivity());
}

}

错误是由这句话引起的:

    queue = Volley.newRequestQueue(getActivity());

有人知道为什么会这样吗?每当我尝试创建新的请求队列时,都会抛出错误。

0 个答案:

没有答案