Exception java.lang.OutOfMemoryError: Failed to allocate a 65548 byte allocation with 55872 free bytes and 54KB until OOM

Exception java.lang.OutOfMemoryError: Failed to allocate a 65548 byte allocation with 55872 free bytes and 54KB until OOM

同类型错误的问题太多了,但我无法找到我的错误的解决方案,我检查了我的不同设备,但仍然无法找到发生此错误的确切位置。我的应用程序目前已上线并安装在 5 万台活动设备上,我通过我的 firebase 收到此错误并且发生了很多次。

 Exception java.lang.OutOfMemoryError: Failed to allocate a 65548 byte allocation with 55872 free bytes and 54KB until OOM
com.android.okhttp.okio.Segment.<init> (Segment.java:62)
com.android.okhttp.okio.SegmentPool.take (SegmentPool.java:46)
com.android.okhttp.okio.Buffer.writableSegment (Buffer.java:1114)
com.android.okhttp.okio.InflaterSource.read (InflaterSource.java:66)
com.android.okhttp.okio.GzipSource.read (GzipSource.java:80)
com.android.okhttp.okio.RealBufferedSource.read (RealBufferedSource.java:374)
bmr.a (:com.google.android.gms.DynamiteModulesC:95)
bmk.a (:com.google.android.gms.DynamiteModulesC:1055)
bmq.a (:com.google.android.gms.DynamiteModulesC:5055)
bmq.run (:com.google.android.gms.DynamiteModulesC:54)
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1113)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:588)
java.lang.Thread.run (Thread.java:818)

您似乎在尝试解压缩一个大文件,这个文件大到耗尽了设备的所有内存。每个设备的可用内存不同。 如果可能,请尝试将文件拆分为更小的块并单独处理它们。否则,请尝试使用流解决方案,您可以在其中使用流解压缩,而不是在开始解压缩之前将整个文件加载到内存中。

试试这个:Unzip using a stream or read documentation here: GZUPInputStream

您似乎已尝试通过 "okhttp" 上传文件。如果是,请尝试使用 "Filepath" 而不是 "File" 作为参数。

只需删除 HttpLoggingInterceptor.Level.BODY