code: private static long getSizeOfPhysicalMemoryForMac() {
  
  		BufferedReader bi = null;
  
  		try {
  			Process proc = Runtime.getRuntime().exec("sysctl hw.memsize");
  
  			bi = new BufferedReader(
  					new InputStreamReader(proc.getInputStream()));
  
  			String line;
  
  			while ((line = bi.readLine()) != null) {
  				if (line.startsWith("hw.memsize")) {
  					long memsize = Long.parseLong(line.split(":")[1].trim());
  					bi.close();
  					proc.destroy();
  					return memsize;
  				}
  			}
  
  		} catch (Exception e) {
  			LOG.error(e);
  			return -1;
  		} finally {
  			if (bi != null) {
  				try {
  					bi.close();
  				} catch (IOException ioe) {
  				}
  			}
  		}
  		return -1;
  	}
docs: Returns the size of the physical memory in bytes on a Mac OS-based
  operating system
  
  @return the size of the physical memory in bytes or <code>-1</code> if
  the size could not be determined