Android 发生 OutofMemory 异常时如何解释消息?

H.K*_*Kim 5 java android out-of-memory

Failed to allocate a 24 byte allocation with 294656 free bytes and 287KB until OOM, target footprint 268435456, growth limit 268435456; failed due to fragmentation (largest possible contiguous allocation 114556928 bytes)
Run Code Online (Sandbox Code Playgroud)

在我服务的应用程序的“正常情况”中(我不使用位图,这是常见的 OOM 中的一个问题。相反,它使用 Http 请求正文,该正文可能非常大),

通过 Android Studio Profiler 检查内存时未检测到内存泄漏。

但对于客户来说,OOM 的情况就像上面的消息一样。(数字略有不同)

在澄清如何调试我的应用程序之前,我想知道该消息的含义。

Failed to allocate a 24 byte allocation
Run Code Online (Sandbox Code Playgroud)

判断尝试创建占用24字节内存的对象失败。


但我不太明白其他字母都在说什么。

Failed to allocate a 24 byte allocation with 294656 free bytes and 287KB until OOM
Run Code Online (Sandbox Code Playgroud)
  1. 当我有287KB的可用空间时,是否会出现无法分配24字节的情况?
failed due to fragmentation (largest possible contiguous allocation 114556928 bytes)
Run Code Online (Sandbox Code Playgroud)
  1. 可用内存区域是256MB,可分配内存区域可以是109MB吗?(我不太明白“连续”的含义)
target footprint 268435456, growth limit 268435456;
Run Code Online (Sandbox Code Playgroud)
  1. 这是否仅意味着应用程序堆的大小(我可以用java代码修改的区域)?或者它是否包含代码堆(可以随着 apk 代码数量增长的区域)?