Finding out system RAM via Java

后端 未结 2 1290
野的像风
野的像风 2021-01-22 22:13

I am writing a program in which i need to do a minimum system RAM validation. How do i go about calculating the RAM of the machine that is executing the code in its JVM ?

2条回答
  •  醉酒成梦
    2021-01-22 22:25

    I think it is not possible with pure java at all.

    Within the JVM you can only mesure the JVM-ram not the System RAM. http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/management/MemoryMXBean.html

    You'll need a piece of native code.

提交回复
热议问题