Package org.jboss.profiler.jvmti

Examples of org.jboss.profiler.jvmti.JVMTIInterface


      }
   }

   private int countInstances(String name)
   {
      JVMTIInterface jvmti = new JVMTIInterface();
      int i = jvmti.getAllObjects(name).length;
      return i;
   }
View Full Code Here


      return testClass;
   }

   private void checkUnload(WeakReference weakReferenceOnLoader, String className) throws Exception
   {
      JVMTIInterface jvmti = new JVMTIInterface();
      if (jvmti.isActive())
      {

         //clearEverySingleFieldOnInstances("org.jboss.aop.AspectManager"); // This part is not intended to be commited. It could be used during debug, and you could use to release references on purpose, just to evaluate behavior

         jvmti.forceReleaseOnSoftReferences();
         jvmti.forceGC();
         Class clazz = jvmti.getClassByName(className);
         if (clazz!=null)
         {
            jvmti.heapSnapshot("snapshot", "mem");
            clazz=null;

            String report =jvmti.exploreClassReferences(className, 15, true, false, false, false, true);

            //System.out.println(report);
            String reportDir = System.getProperty("leak.report.dir");
            assertNotNull("You must pass in the directory for the reports as leak.report.dir", reportDir);
            File outputfile = new File(reportDir + "/leak-reoprt-" + className + ".html");
            FileOutputStream outfile = new FileOutputStream(outputfile);
            PrintStream realoutput = new PrintStream(outfile);
            realoutput.println(report);
            realoutput.close();


            jvmti.forceGC();

            clazz = jvmti.getClassByName(className);

            clearEverySingleFieldOnInstances("org.jboss.aop.AspectManager"); // This part is not intended to be commited. It could be used during debug, and you could use to release references on purpose, just to evaluate behavior

            clazz = jvmti.getClassByName(className);
            if (clazz==null)
            {
                System.out.println("Attention: After clearing every field on AspectManager, GC could release the classLoader");
            }
View Full Code Here

      }
   }

   private void reportInstanceReferences(WeakReference weakReferenceOnLoader, String className) throws Exception
   {
      JVMTIInterface jvmti = new JVMTIInterface();
      if (jvmti.isActive())
      {

         jvmti.forceReleaseOnSoftReferences();
         jvmti.forceGC();
         Class clazz = jvmti.getClassByName(className);
         if (clazz!=null)
         {
            jvmti.heapSnapshot("snapshot", "mem");
            clazz=null;
            Object[] objects = jvmti.getAllObjects(className);
            System.out.println("============> Instances of " + className + " " + objects.length);

            //String report =jvmti.exploreClassReferences(className, 15, true, false, false, false, true);
            String report = jvmti.exploreObjectReferences(className, 15, false);



            System.out.println("================= " + className + " ================");
            System.out.println(report);
View Full Code Here


   private void clearEverySingleFieldOnInstances(String className)
   {
      System.out.println("Clearing " + className);
      JVMTIInterface jvmti = new JVMTIInterface();
      Class classes[] = jvmti.getLoadedClasses();
      Object objects[] = null;

      for (int i=0;i<classes.length;i++)
      {
         if (classes[i].getName().equals(className))
         {
          System.out.println("---> Found class " + className);
            Field fields[] = getDeclaredFields(classes[i]);
            objects = jvmti.getAllObjects(classes[i]);
            for (int j=0;j<objects.length;j++)
            {
               resetObject(objects[j], fields);
              
            }
View Full Code Here

     Class<?> simpleBeanInterface = loader.loadClass("org.jboss.test.classinfo.support.SimpleInterface");
     ClassInfo cinfo = getClassInfo(loader,simpleBeanClass);
     cinfo=null;
    
     // Test if the reference on ClassInfo is not too weak
     JVMTIInterface jvmti = new JVMTIInterface();
     if (jvmti.isActive())
     {
        jvmti.forceGC();
        assertEquals(1,jvmti.getAllObjects(ClassInfo.class).length);
     }

    
     cinfo = getClassInfo(loader,simpleBeanClass);
      assertEquals(simpleBeanClass.getName(), cinfo.getName());
View Full Code Here

      conn.start();
      MessageConsumer cons = sess.createConsumer(queue);

      produceMessages(sess, prod, 100, cons);
     
      JVMTIInterface jvmti = new JVMTIInterface();
      Map inventory1=jvmti.produceInventory();
      log.info("Producing first snapshot");
      produceMessages(sess, prod, NUM_MESSAGES, cons);
      log.info("Producing second snapshot");
      jvmti.forceReleaseOnSoftReferences();
      jvmti.forceGC();
      Map inventory2 = jvmti.produceInventory();
     
      log.info("inventory1.size=" + inventory1.size());
      log.info("inventory2.size=" + inventory2.size());
     
      assertTrue("Test produced unexpected objects",jvmti.compareInventories(System.out, inventory1,inventory2,null, null, new InventoryDataPoint[] {new InventoryDataPoint(Object.class,10)}));
           
      conn.close();
     
      conn = null;
     
View Full Code Here

      MessageConsumer cons1 = sess.createConsumer(queue,"target='1'");
      MessageConsumer cons2 = sess.createConsumer(queue,"target='2'");

      produceMessages(sess, prod, 30, cons1,cons2,payLoad);
     
      JVMTIInterface jvmti = new JVMTIInterface();
      Map inventory1=jvmti.produceInventory();
      log.info("Producing first snapshot");
      produceMessages(sess, prod, 10, cons1,cons2,payLoad);
      produceMessages(sess, prod, 10, cons1,cons2,payLoad);
      produceMessages(sess, prod, 10, cons1,cons2,payLoad);
      produceMessages(sess, prod, 10, cons1,cons2,payLoad);
      produceMessages(sess, prod, 10, cons1,cons2,payLoad);
      produceMessages(sess, prod, 10, cons1,cons2,payLoad);
      log.info("Producing second snapshot");
      Map inventory2 = jvmti.produceInventory();
     
      log.info("inventory1.size=" + inventory1.size());
      log.info("inventory2.size=" + inventory2.size());
     
      assertTrue("Test produced unexpected objects",jvmti.compareInventories(System.out, inventory1,inventory2,null, null, new InventoryDataPoint[] {new InventoryDataPoint(Object.class,10)}));
     
      conn.close();
     
      conn = null;
     
View Full Code Here

TOP

Related Classes of org.jboss.profiler.jvmti.JVMTIInterface

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.