From 0b8fa1438a20860757fe17efee14fb38525fcc5d Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Wed, 9 Nov 2005 18:38:33 +0000 Subject: [PATCH] setup/shutdown dmalloc --- bindings/java/src/jni/javasigar.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/bindings/java/src/jni/javasigar.c b/bindings/java/src/jni/javasigar.c index 5573ac2c..0814371b 100644 --- a/bindings/java/src/jni/javasigar.c +++ b/bindings/java/src/jni/javasigar.c @@ -54,6 +54,31 @@ typedef struct { sigar = jsigar->sigar; \ jsigar->env = env +JNIEXPORT jint JNICALL +JNI_OnLoad(JavaVM *vm, void *reserved) +{ +#ifdef DMALLOC + char *options = + getenv("DMALLOC_OPTIONS"); + if (!options) { + options = + "debug=0x4f47d03," + "lockon=20," + "log=dmalloc-sigar.log"; + } + dmalloc_debug_setup(options); +#endif + return JNI_VERSION_1_2; +} + +JNIEXPORT void JNICALL +JNI_OnUnload(JavaVM *vm, void *reserved) +{ +#ifdef DMALLOC + dmalloc_shutdown(); +#endif +} + static void sigar_throw_exception(JNIEnv *env, char *msg) { jclass errorClass = SIGAR_FIND_CLASS("SigarException");