java - freeMemory() 和 totalMemory() 的区别
问题描述
freeMemory()
和有什么区别totalMemory()
?两者都是当前可用于 JVM 的内存总量。
/**
*
* @return an approximation to the total amount of memory currently
* available for future allocated objects, measured in bytes.
*/
public native long freeMemory();
/**
*
* @return the total amount of memory currently available for current
* and future objects, measured in bytes.
*/
public native long totalMemory();
解决方案
freeMemory()
说for future
,totalMemory()
说for current and future
。
从字面上看,freeMemory()
告诉新分配对象的内存并totalMemory()
告诉总内存(已分配的内存+空闲内存)
推荐阅读
- c# - C# 无法从“输出字符串”转换为“输出动态”
- caching - AMP 更新缓存导致来自源的 404 或 410 错误
- docker - 在 Windows Docker 下运行的 IBM MQ 客户端
- c# - 我在动态创建的 SQL 语句中遇到语法错误,靠近 LIKE 运算符
- javascript - 令牌不会自动更新 Angular 和 ADAL.js
- java - 从自动建议下拉列表中获取文本在 Selenium 中不起作用
- c# - C# dll System.Reflection.TargetInvocationException 错误
- github - 如何为我的 GitHub 存储库提供多个彩色圆圈“技术徽章”?
- azure - 如何使用 terraform 将 Azure 应用服务与应用程序洞察资源(新的或现有的)相关联?
- reactjs - 尝试在 Windows 10 中安装 react js。但我每次都收到此错误