“ xx个空闲字节和xx直到OOM意味着什么?

问题描述 投票:3回答:1

我在Android应用中java.lang.OutOfMemoryError: Failed to allocate a 32 byte allocation with 0 free bytes and 3GB until OOM遇到了这样的例外。 0个空闲字节是什么意思?和3GB?

java android out-of-memory
1个回答
0
投票

0个空闲字节意味着确切地说。我不明白的地方是3GB until next OOM

我扎根于Android源,在这里您会看到此错误(在某些随机版本的Android中,我不确定是哪个)

https://android.googlesource.com/platform/art/+/dd162fb5990cedf80a5093ecc0e77df82af5f754/runtime/gc/heap.cc#872

 oss << "Failed to allocate a " << byte_count << " byte allocation with " << 
 total_bytes_free
 << " free bytes and " << PrettySize(GetFreeMemoryUntilOOME()) << " until OOM";

3GB是GetFreeMemoryUntilOOME功能,看起来是这样:

// Returns approximately how much free memory we have until the next OOME happens.
size_t GetFreeMemoryUntilOOME() const {
  return growth_limit_ - GetBytesAllocated();
}

我不确定什么是growth_limit,但是从读取的内容来看,这是最大堆大小?

从Android来源猜测,这确实是一个可怕的答案,但这里没有其他内容,因此我将其发布!

© www.soinside.com 2019 - 2024. All rights reserved.