Android OkHttp在进行https调用时出现OutOfMemory错误

时间:2017-01-18 04:30:58

标签: android out-of-memory retrofit2 okhttp okhttp3

我正在使用改造,okhttp在我的应用程序中进行网络调用。

最近,应用程序用户在发出请求时遇到了奇怪的OOM崩溃。

问题的堆栈跟踪是:

Caused by java.lang.OutOfMemoryError: Failed to allocate a 39950 byte allocation with 8388512 free bytes and 62MB until OOM
   at libcore.io.IoUtils$FileReader.(IoUtils.java)
   at libcore.io.IoUtils.readFileAsString(IoUtils.java:116)
   at com.android.org.conscrypt.CertPinManager.readPinFile(CertPinManager.java:120)
   at com.android.org.conscrypt.CertPinManager.ensureInitialized(CertPinManager.java:92)
   at com.android.org.conscrypt.CertPinManager.lookup(CertPinManager.java:136)
   at com.android.org.conscrypt.CertPinManager.isChainValid(CertPinManager.java:72)
   at com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:302)
   at com.android.org.conscrypt.TrustManagerImpl.checkServerTrusted(TrustManagerImpl.java:219)
   at com.android.org.conscrypt.Platform.checkServerTrusted(Platform.java:113)
   at com.android.org.conscrypt.OpenSSLSocketImpl.verifyCertificateChain(OpenSSLSocketImpl.java:525)
   at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(NativeCrypto.java)
   at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:302)
   at okhttp3.internal.connection.RealConnection.connectTls(SourceFile:241)
   at okhttp3.internal.connection.RealConnection.establishProtocol(SourceFile:198)
   at okhttp3.internal.connection.RealConnection.buildConnection(SourceFile:174)
   at okhttp3.internal.connection.RealConnection.connect(SourceFile:114)
   at okhttp3.internal.connection.StreamAllocation.findConnection(SourceFile:193)
   at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(SourceFile:129)
   at okhttp3.internal.connection.StreamAllocation.newStream(SourceFile:98)
   at okhttp3.internal.connection.ConnectInterceptor.intercept(SourceFile:42)
   at okhttp3.internal.http.RealInterceptorChain.proceed(SourceFile:92)
   at okhttp3.internal.http.RealInterceptorChain.proceed(SourceFile:67)
   at okhttp3.internal.cache.CacheInterceptor.intercept(SourceFile:109)
   at okhttp3.internal.http.RealInterceptorChain.proceed(SourceFile:92)
   at okhttp3.internal.http.RealInterceptorChain.proceed(SourceFile:67)
   at okhttp3.internal.http.BridgeInterceptor.intercept(SourceFile:93)
   at okhttp3.internal.http.RealInterceptorChain.proceed(SourceFile:92)
   at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(SourceFile:124)
   at okhttp3.internal.http.RealInterceptorChain.proceed(SourceFile:92)
   at okhttp3.internal.http.RealInterceptorChain.proceed(SourceFile:67)
   at okhttp3.logging.HttpLoggingInterceptor.intercept(SourceFile:212)
   at okhttp3.internal.http.RealInterceptorChain.proceed(SourceFile:92)
   at okhttp3.internal.http.RealInterceptorChain.proceed(SourceFile:67)
   at okhttp3.RealCall.getResponseWithInterceptorChain(SourceFile:170)
   at okhttp3.RealCall.execute(SourceFile:60)
   at retrofit2.OkHttpCall.execute(SourceFile:174)
   at retrofit2.adapter.rxjava.RxJavaCallAdapterFactory$RequestArbiter.request(SourceFile:171)
   at rx.internal.producers.ProducerArbiter.setProducer(SourceFile:126)
   at rx.internal.operators.OperatorOnErrorResumeNextViaFunction$4.setProducer(SourceFile:158)
   at rx.Subscriber.setProducer(SourceFile:205)
   at retrofit2.adapter.rxjava.RxJavaCallAdapterFactory$CallOnSubscribe.call(SourceFile:152)
   at retrofit2.adapter.rxjava.RxJavaCallAdapterFactory$CallOnSubscribe.call(SourceFile:138)
   at rx.internal.operators.OnSubscribeLift.call(SourceFile:50)
   at rx.internal.operators.OnSubscribeLift.call(SourceFile:30)
   at rx.internal.operators.OnSubscribeLift.call(SourceFile:50)
   at rx.internal.operators.OnSubscribeLift.call(SourceFile:30)
   at rx.Observable.unsafeSubscribe(SourceFile:8460)
   at rx.internal.operators.OnSubscribeRedo$2.call(SourceFile:278)
   at rx.internal.schedulers.TrampolineScheduler$InnerCurrentThreadScheduler.enqueue(SourceFile:76)
   at rx.internal.schedulers.TrampolineScheduler$InnerCurrentThreadScheduler.schedule(SourceFile:55)
   at rx.internal.operators.OnSubscribeRedo$5.request(SourceFile:366)
   at rx.internal.operators.OperatorSubscribeOn$1$1$1.request(SourceFile:80)
   at rx.Subscriber.setProducer(SourceFile:211)
   at rx.internal.operators.OperatorSubscribeOn$1$1.setProducer(SourceFile:76)
   at rx.internal.operators.OnSubscribeRedo.call(SourceFile:358)
   at rx.internal.operators.OnSubscribeRedo.call(SourceFile:55)
   at rx.Observable.unsafeSubscribe(SourceFile:8460)
   at rx.internal.operators.OperatorSubscribeOn$1.call(SourceFile:94)
   at rx.internal.schedulers.ScheduledAction.run(SourceFile:55)
   at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
   at java.util.concurrent.FutureTask.run(FutureTask.java:237)
   at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:152)
   at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:265)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
   at java.lang.Thread.run(Thread.java:818)

我无法找出导致此次崩溃的原因。

我没有从输入流下载图像或创建位图,上面的日志表明在读取证书文件时内存不足。

0 个答案:

没有答案