All Downloads are FREE. Search and download functionalities are using the official Maven repository.

water.util.OSUtils Maven / Gradle / Ivy

There is a newer version: 3.8.2.9
Show newest version
package water.util;

import java.lang.management.ManagementFactory;

import javax.management.MBeanServer;
import javax.management.ObjectName;

public class OSUtils {

 /** Safe call to obtain size of total physical memory.
  *
  * 

It is platform dependent and returns size of machine physical * memory in bytes

* * @return total size of machine physical memory in bytes or -1 if the attribute is not available. */ public static long getTotalPhysicalMemory() { long memory = -1; try { MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer(); Object attribute = mBeanServer.getAttribute(new ObjectName("java.lang","type","OperatingSystem"), "TotalPhysicalMemorySize"); return (Long) attribute; } catch (Throwable e) { e.printStackTrace(); } return memory; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy