gpt4 book ai didi

java - 如何在 j2me 中通过电话获取最大可用堆大小?

转载 作者:行者123 更新时间:2023-11-30 11:53:13 24 4
gpt4 key购买 nike

由于堆大小限制,我的 Midlet 需要针对不同的堆大小以不同的方式执行操作。例如,它应该加载更多或更少的位图字体。

最佳答案

// Get current size of heap in bytes
long heapSize = Runtime.getRuntime().totalMemory();

// Get maximum size of heap in bytes. The heap cannot grow beyond this size.
// Any attempt will result in an OutOfMemoryException.
long heapMaxSize = Runtime.getRuntime().maxMemory();

// Get amount of free memory within the heap in bytes. This size will increase
// after garbage collection and decrease as new objects are created.
long heapFreeSize = Runtime.getRuntime().freeMemory();

另请参阅 Runtime Java Documentation.

关于java - 如何在 j2me 中通过电话获取最大可用堆大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6427087/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com