1 /* src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c
3 Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
4 C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5 E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6 J. Wenninger, Institut f. Computersprachen - TU Wien
8 This file is part of CACAO.
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2, or (at
13 your option) any later version.
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 $Id: VMFrame.c 4996 2006-05-31 13:53:16Z motse $
33 #include "mm/gc-common.h"
35 #include "native/jni.h"
36 #include "native/include/java_lang_management_MemoryUsage.h"
38 #include "vm/builtin.h"
39 #include "vm/global.h"
42 #include "vmcore/class.h"
43 #include "vmcore/loader.h" /* XXX only for load_class_bootstrap */
44 #include "vmcore/options.h"
48 * Class: gnu/java/lang/management/VMMemoryMXBeanImpl
49 * Method: getHeapMemoryUsage
50 * Signature: ()Ljava/lang/management/MemoryUsage;
52 JNIEXPORT java_lang_management_MemoryUsage* JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getHeapMemoryUsage(JNIEnv *env, jclass clazz)
54 classinfo *class_java_lang_management_MemoryUsage;
56 java_lang_management_MemoryUsage *mu;
64 /* XXX optimize me! sometime... */
66 if (!(class_java_lang_management_MemoryUsage = load_class_bootstrap(utf_new_char("java/lang/management/MemoryUsage"))))
69 /* create the object */
71 o = builtin_new(class_java_lang_management_MemoryUsage);
76 /* cast the object to a MemoryUsage object (for debugability) */
78 mu = (java_lang_management_MemoryUsage *) o;
80 /* find initializer */
82 m = class_findmethod(class_java_lang_management_MemoryUsage,
83 utf_init, utf_new_char("(JJJJ)V"));
85 /* initializer not found */
90 /* get values from the VM */
91 /* XXX if we ever support more than one VM, change this */
93 init = opt_heapstartsize;
94 used = gc_get_total_bytes();
95 commited = gc_get_heap_size();
96 maximum = gc_get_max_heap_size();
98 /* call initializer */
100 (void) vm_call_method(m, o, init, used, commited, maximum);
107 * Class: gnu/java/lang/management/VMMemoryMXBeanImpl
108 * Method: getNonHeapMemoryUsage
109 * Signature: ()Ljava/lang/management/MemoryUsage;
111 JNIEXPORT java_lang_management_MemoryUsage* JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getNonHeapMemoryUsage(JNIEnv *env, jclass clazz)
113 log_println("Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getNonHeapMemoryUsage: IMPLEMENT ME!");
120 * Class: gnu/java/lang/management/VMMemoryMXBeanImpl
121 * Method: getObjectPendingFinalizationCount
124 JNIEXPORT s4 JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getObjectPendingFinalizationCount(JNIEnv *env, jclass clazz)
126 log_println("Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getObjectPendingFinalizationCount: IMPLEMENT ME!");
133 * Class: gnu/java/lang/management/VMMemoryMXBeanImpl
137 JNIEXPORT s4 JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_isVerbose(JNIEnv *env, jclass clazz)
139 return _Jv_jvm->Java_gnu_java_lang_management_VMMemoryMXBeanImpl_verbose;
144 * Class: gnu/java/lang/management/VMMemoryMXBeanImpl
148 JNIEXPORT void JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_setVerbose(JNIEnv *env, jclass clazz, s4 verbose)
150 _Jv_jvm->Java_gnu_java_lang_management_VMMemoryMXBeanImpl_verbose = verbose;
155 * These are local overrides for various environment variables in Emacs.
156 * Please do not remove this and leave it at the end of the file, where
157 * Emacs will automagically detect them.
158 * ---------------------------------------------------------------------
161 * indent-tabs-mode: t
165 * vim:noexpandtab:sw=4:ts=4: