[jboss-cvs] JBoss Profiler SVN: r559 - in branches/JBossProfiler2/src: native and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Aug 14 18:09:10 EDT 2009
Author: clebert.suconic at jboss.com
Date: 2009-08-14 18:09:10 -0400 (Fri, 14 Aug 2009)
New Revision: 559
Added:
branches/JBossProfiler2/src/test/java/org/jboss/profiler/test/jvmti/StressReportTest.java
Modified:
branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/JVMTIInterface.java
branches/JBossProfiler2/src/native/agent.cpp
Log:
a few tweaks
Modified: branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/JVMTIInterface.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/JVMTIInterface.java 2009-08-12 04:33:52 UTC (rev 558)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/jvmti/JVMTIInterface.java 2009-08-14 22:09:10 UTC (rev 559)
@@ -60,12 +60,21 @@
{
try
{
- System.loadLibrary("JBossProfiler");
+ JVMTIInterface tst = new JVMTIInterface();
+ // if this works, the profiler is already loaded
+ tst.forceGC();
}
catch (Throwable e)
{
- isLoaded = false;
- System.out.println("The DLL/SO couldn't be loaded, you won't be able to use any JVMTIInterface feature");
+ try
+ {
+ System.loadLibrary("JBossProfiler");
+ }
+ catch (Throwable e2)
+ {
+ isLoaded = false;
+ System.out.println("The DLL/SO couldn't be loaded, you won't be able to use any JVMTIInterface feature");
+ }
}
}
@@ -1296,7 +1305,7 @@
* Returns a WeakHashMap<Class,InventoryDataPoint> summarizing the current
* JVM's inventory.
* */
- public Map<Class<?>, InventoryDataPoint> produceInventory() throws IOException
+ public synchronized Map<Class<?>, InventoryDataPoint> produceInventory() throws IOException
{
forceGC();
InnerCallBack callBack = new InnerCallBack();
@@ -1328,7 +1337,7 @@
}
/** Will list the current memory inventory. Exposed through JMX. */
- public String inventoryReport(final boolean html) throws Exception
+ public synchronized String inventoryReport(final boolean html) throws Exception
{
Map map = produceInventory();
Modified: branches/JBossProfiler2/src/native/agent.cpp
===================================================================
--- branches/JBossProfiler2/src/native/agent.cpp 2009-08-12 04:33:52 UTC (rev 558)
+++ branches/JBossProfiler2/src/native/agent.cpp 2009-08-14 22:09:10 UTC (rev 559)
@@ -825,6 +825,11 @@
fread((void *) &bytes,sizeof(bytes),1,iterate.fileObjects);
env->CallVoidMethod(jvmtiCallBack,notifyMethodObject,classTag,objectTag,bytes);
}
+
+ if (fclose(iterate.fileObjects))
+ {
+ fprintf (stderr,"Error on closing file on profiler\n");
+ }
}
@@ -839,6 +844,8 @@
jbyte referenceType=0;
jmethodID method;
jlong methodParameter=0;
+
+ fprintf (stderr,"I'm here");
while (!feof(iterate.fileReferences))
{
fread((void *) &referenceHolder,sizeof(referenceHolder),1,iterate.fileReferences);
@@ -853,7 +860,10 @@
env->CallVoidMethod(jvmtiCallBack,notifyMethod,referenceHolder,referencedObject,classTag, index,methodParameter,referenceType);
}
- fclose(iterate.fileReferences);
+ if (fclose(iterate.fileReferences))
+ {
+ fprintf (stderr,"Error on closing file on profiler\n");
+ }
}
verifyError(err);
Added: branches/JBossProfiler2/src/test/java/org/jboss/profiler/test/jvmti/StressReportTest.java
===================================================================
--- branches/JBossProfiler2/src/test/java/org/jboss/profiler/test/jvmti/StressReportTest.java (rev 0)
+++ branches/JBossProfiler2/src/test/java/org/jboss/profiler/test/jvmti/StressReportTest.java 2009-08-14 22:09:10 UTC (rev 559)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+
+package org.jboss.profiler.test.jvmti;
+
+import org.jboss.profiler.jvmti.JVMTIInterface;
+
+import junit.framework.TestCase;
+
+/**
+ * A StressReportTest
+ *
+ * @author <mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+public class StressReportTest extends TestCase
+{
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ public void testReports() throws Exception
+ {
+ long i = 0;
+
+ JVMTIInterface jvmti = new JVMTIInterface();
+
+ while (true)
+ {
+ if (i ++ % 100 == 0)
+ {
+ System.out.println("i = " + i);
+ }
+ jvmti.inventoryReport();
+ }
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
More information about the jboss-cvs-commits
mailing list