KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > webservices > memory > Memory


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.cocoon.webservices.memory;
17
18 /**
19  * Class which provides JVM memory related SOAP services.
20  *
21  * @author <a HREF="mailto:crafterm@apache.org">Marcus Crafter</a>
22  * @version CVS $Id: Memory.java 53741 2004-10-04 19:24:11Z vgritsenko $
23  */

24 public class Memory {
25
26     // static reference to the runtime object.
27
private static final Runtime JavaDoc runtime = Runtime.getRuntime();
28
29     /**
30      * <code>getFreeMemory</code> returns the amount of free memory
31      * in the system.
32      *
33      * @return the amount of free memory in the system
34      */

35     public static long getFreeMemory() {
36         return runtime.freeMemory();
37     }
38
39     /**
40      * <code>getTotalMemory</code> returns the total amount of memory
41      * in the JVM.
42      *
43      * @return the total amount of memory in the JVM
44      */

45     public static long getTotalMemory() {
46         return runtime.totalMemory();
47     }
48
49     /**
50      * <code>invokeGC</code> calls upon the JVM Garbage Collector to
51      * recycle unused objects.
52      */

53     public static void invokeGC() {
54         runtime.gc();
55     }
56 }
57
Popular Tags