qiniu / android-sdk

Qiniu Resource (Cloud) Storage SDK for Android
MIT License
626 stars 226 forks source link

app长时间处于后台报错如下 #515

Open yx1025 opened 2 months ago

yx1025 commented 2 months ago

java.lang.OutOfMemoryError: pthread_create (1040KB stack) failed: Try again at java.lang.Thread.nativeCreate(Thread.java) at java.lang.Thread.start(Thread.java:883) at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:975) at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1382) at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:118) at com.qiniu.android.dns.dns.DnsResolver.request(DnsResolver.java:114) at com.qiniu.android.dns.dns.DnsResolver.lookupHost at com.qiniu.android.dns.dns.DnsResolver.resolve(DnsResolver.java:52) at com.qiniu.android.http.dns.HttpDns.lookup(HttpDns.java:44) at com.qiniu.android.http.dns.DnsPrefetcher.preFetchHost(DnsPrefetcher.java:299) at com.qiniu.android.http.dns.DnsPrefetcher.preFetchHosts(DnsPrefetcher.java:265) at com.qiniu.android.http.dns.DnsPrefetcher.preFetchHosts(DnsPrefetcher.java:237) at com.qiniu.android.http.dns.DnsPrefetcher.checkWhetherCachedDnsValid(DnsPrefetcher.java:191) at com.qiniu.android.http.dns.DnsPrefetchTransaction$4.run at com.qiniu.android.transaction.TransactionManager$Transaction.handleAction(TransactionManager.java:214) at com.qiniu.android.transaction.TransactionManager$Transaction.access$000 at com.qiniu.android.transaction.TransactionManager.handleTransaction at com.qiniu.android.transaction.TransactionManager.handleAllTransaction(TransactionManager.java:92) at com.qiniu.android.transaction.TransactionManager.timerAction(TransactionManager.java:124) at com.qiniu.android.transaction.TransactionManager.access$100 at com.qiniu.android.transaction.TransactionManager$1.run at java.util.TimerThread.mainLoop(Timer.java:562) at java.util.TimerThread.run(Timer.java:512)

YangSen-qn commented 2 months ago

@yx1025 看起来是手机内存使用问题,可能和手机内存大小有关,也可能和其他 APP 有关,只不过七牛 SDK 在申请内存时正好触发了 OOM。

七牛 SDK 使用时的注意点:

  1. 上传时尽可能控制并发上传得文件数量(比如:3个),这是 APP 需要实现的逻辑
  2. 上传分片配置不要太大,我们推荐使用默认值
  3. 上传分片阈值不要太大,我们推荐使用默认值