尝试发送带附件的电子邮件时,我发现内存不足异常。
不幸的是,除非我增加堆分配的大小,否则我似乎无法诊断/解决问题。据我所知,附件并不是特别大,它适用于某些安装但不适用于其他安装。
07-18 15:29:58.912 2471-21587/uk.co.nwhub.nwtapp E/art: Throwing OutOfMemoryError "Failed to allocate a 37440820 byte allocation with 16777120 free bytes and 18MB until OOM"
07-18 15:29:58.922 2471-21587/uk.co.nwhub.nwtapp E/AndroidRuntime: FATAL EXCEPTION: IntentService[EmailService]
Process: uk.co.nwhub.nwtapp, PID: 2471
java.lang.OutOfMemoryError: Failed to allocate a 37440820 byte allocation with 16777120 free bytes and 18MB until OOM
at java.lang.AbstractStringBuilder.enlargeBuffer(AbstractStringBuilder.java:95)
at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:133)
at java.lang.StringBuilder.append(StringBuilder.java:124)
at libcore.net.UriCodec.appendEncoded(UriCodec.java:119)
at libcore.net.UriCodec.encode(UriCodec.java:133)
at java.net.URLEncoder.encode(URLEncoder.java:57)
at com.amazonaws.util.HttpUtils.urlEncode(HttpUtils.java:74)
at com.amazonaws.auth.AbstractAWSSigner.getCanonicalizedQueryString(AbstractAWSSigner.java:173)
at com.amazonaws.auth.AWS3Signer.sign(AWS3Signer.java:112)
at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:326)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:199)
at com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient.invoke(AmazonSimpleEmailServiceClient.java:2630)
at com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient.sendRawEmail(AmazonSimpleEmailServiceClient.java:1525)
at uk.co.nwhub.nwtapp.services.EmailService.onHandleIntent(EmailService.java:126)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.os.HandlerThread.run(HandlerThread.java:61)
我正在阅读的所有帮助/指导都说明了在处理图像时如何处理这种情况。但是,我没有在此活动中使用任何图像。我该怎么做才能诊断/尝试解决这个问题?
答案 0 :(得分:0)
您可以在com.amazonaws.util.HttpUtils.urlEncode(HttpUtils.java:74)
设置断点,
然后通过“Debug app”运行应用程序,并检查非常大的字符串