KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jgap > util > SystemKit


1 /*
2  * This file is part of JGAP.
3  *
4  * JGAP offers a dual license model containing the LGPL as well as the MPL.
5  *
6  * For licencing information please see the file license.txt included with JGAP
7  * or have a look at the top of class org.jgap.Chromosome which representatively
8  * includes the JGAP license policy applicable for any file delivered with JGAP.
9  */

10 package org.jgap.util;
11
12 /**
13  * System-related utility functions.
14  *
15  * @author Klaus Meffert
16  * @since 3.2
17  */

18 public class SystemKit {
19   /** String containing the CVS revision. Read out via reflection!*/
20   private final static String JavaDoc CVS_REVISION = "$Revision: 1.1 $";
21
22   /**
23    * @return total memory available by the VM in megabytes.
24    *
25    * @author Klaus Meffert
26    * @since 3.2 (since 3.0 in GPGenotype)
27    */

28   public static double getTotalMemoryMB() {
29     return (Runtime.getRuntime().totalMemory() / 1024 / 1024);
30   }
31
32   /**
33    * @return free memory available in the VM in megabytes.
34    *
35    * @author Klaus Meffert
36    * @since 3.0 (since 3.0 in GPGenotype)
37    */

38   public static double getFreeMemoryMB() {
39     return (Runtime.getRuntime().freeMemory() / 1024 / 1024);
40   }
41 }
42
Popular Tags