我在Android应用中java.lang.OutOfMemoryError: Failed to allocate a 32 byte allocation with 0 free bytes and 3GB until OOM
遇到了这样的例外。 0个空闲字节是什么意思?和3GB?
0个空闲字节意味着确切地说。我不明白的地方是3GB until next OOM
我扎根于Android源,在这里您会看到此错误(在某些随机版本的Android中,我不确定是哪个)
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来源猜测,这确实是一个可怕的答案,但这里没有其他内容,因此我将其发布!