英文:
Java method to return the OS ram usage in unix
问题
我想创建一个方法来返回主操作系统的内存使用情况,而不是我尝试使用RunTime类并且它只返回JVM内存使用情况,但我想要的是操作系统级别的。
英文:
I want to create a method to return the ram usage in the main OS NOT THE OS I tried the RunTime class and it return only the JVM ram usage, but I want it for the OS level
答案1
得分: 0
如果您不需要可移植性,您可以阅读 /proc/meminfo,这可能是您正在寻找的内容,并且应该很容易解析。
但需要注意的是,旧的内核版本可能具有较少的信息行。有关详细信息,请参阅 https://access.redhat.com/solutions/406773。
英文:
If you don't need portability you could read /proc/meminfo it might be what you are looking for and should be straight forward to parse.
A word of warning though, older kernel versions may have fewer rows of information. See for details https://access.redhat.com/solutions/406773
专注分享java语言的经验与见解,让所有开发者获益!
评论