OkHttp3 icon indicating copy to clipboard operation
OkHttp3 copied to clipboard

在依次发送多个请求后,出现java.lang.OutOfMemoryError错误

Open lyx383982759 opened this issue 7 years ago • 4 comments

01-12 16:37:23.970 6489-7775/line.red.ths.com.cn.redline E/AndroidRuntime: FATAL EXCEPTION: OkHttp Dispatcher Process: line.red.ths.com.cn.redline, PID: 6489 java.lang.OutOfMemoryError: pthread_create (1040KB stack) failed: Out of memory at java.lang.Thread.nativeCreate(Native Method) at java.lang.Thread.start(Thread.java:1076) at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:920) at java.util.concurrent.ThreadPoolExecutor.processWorkerExit(ThreadPoolExecutor.java:988) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) at java.lang.Thread.run(Thread.java:831)

lyx383982759 avatar Jan 12 '18 08:01 lyx383982759

依赖的是最新的版本吗?

MrZhousf avatar Jan 13 '18 03:01 MrZhousf

是最新版本的。我也尝试换了之前的版本也都是会报错,使用的是OkHttpUtil.getDefault().doPostAsync这个放啊请求的,在依次发送多个请求后程序不会立即报错,而是过了几秒钟或者几十秒中后才报的错误,APP也就退出了。

lyx383982759 avatar Jan 14 '18 03:01 lyx383982759

可以发下请求代码片段吗,如果可以发demo那就更好了。

MrZhousf avatar Jan 14 '18 05:01 MrZhousf

新版本可以解决, 多次new OkhttpClient 实例.

yangjieK avatar Jan 15 '18 03:01 yangjieK