Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Can not use

Help
2010-05-04
2014-02-04
  • Avihay Tsayeg
    Avihay Tsayeg
    2010-05-04

    Hi,
    Trying using Got an error, need some help here.

    java.lang.IllegalStateException: Instrumentation is null

        public void getObjectSize(Object o){
           // import net.sourceforge.sizeof
             SizeOf.skipStaticField(true); //java.sizeOf will not compute static fields
             SizeOf.skipFinalField(true); //java.sizeOf will not compute final fields
           
             SizeOf.skipFlyweightObject(true); //java.sizeOf will not compute well-known flyweight objects
            try{

                System.out.println(SizeOf.humanReadable(SizeOf.deepSizeOf(o))); //this will print the object size in bytes
            }catch (RuntimeException e){
                e.printStackTrace();
            }

     
  • smi
    smi
    2010-05-24

    You need to start your jvm with this argument:  -javaagent:<path to>/SizeOf.jar

     
  • freeHoon
    freeHoon
    2011-11-23

    I have a project in eclipse and i have used sizeOf . But when i run the application, it shows
    Exception in thread "main" java.lang.IllegalStateException: Instrumentation is null
    at net.sourceforge.sizeof.SizeOf.sizeOf(SizeOf.java:59)
    at net.sourceforge.sizeof.SizeOf.deepSizeOf(SizeOf.java:145)
    at net.sourceforge.sizeof.SizeOf.deepSizeOf(SizeOf.java:102)

    I have added jar file in build path. I don't know how to use -javaagent in eclipse. Can anyone please explain me in detail the procedure to use this jar file.

     
  • Lucas B.
    Lucas B.
    2011-12-01

    Just put the -javaagent argument in the "VM arguments" field in your Run Configuration.

     
  • Hello everybody:

    Unfortunatelly I have the same error,  I am using JBoss 6.0 SA , JSF Primefaces and SQL Server.

    The point is that i have changed my JBoss configuration and I have added the following line to the VM arguments

    set "JAVA_OPTS=%JAVA_OPTS% -javaagent:sizeOf.jar"

    Even when I start JBoss 6 I see that the agent is loaded

    Calling D:\Dev\Programs\Servers\JBoss\jboss-6.0.0.Final\bin\run.conf.bat
    ===============================================================================
      JBoss Bootstrap Environment
      JBOSS_HOME: D:\Dev\Programs\Servers\JBoss\jboss-6.0.0.Final
      JAVA: D:\Dev\Programs\Java\jdk1.6.0_21\bin\java
      JAVA_OPTS: -Dprogram.name=run.bat -Xms128M -Xmx512M -XX:MaxPermSize=256M -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Dorg.jboss.resolver.warning=true -javaagent:sizeOf.jar -server
      CLASSPATH: D:\Dev\Programs\Java\jdk1.6.0_21\lib\tools.jar;D:\Dev\Programs\Servers\JBoss\jboss-6.0.0.Final\bin\run.jar
    ===============================================================================
    JAVAGENT: call premain instrumentation for class SizeOf
    10:51:58,923 INFO  [AbstractJBossASServerBase] Server Configuration:
            JBOSS_HOME URL: file:/D:/Dev/Programs/Servers/JBoss/jboss-6.0.0.Final/
            Bootstrap: $JBOSS_HOME\server/ecoemos/conf/bootstrap.xml
            Common Base: $JBOSS_HOME\common/
            Common Library: $JBOSS_HOME\common/lib/
            Server Name: ecoemos
            Server Base: $JBOSS_HOME\server/
            Server Library: $JBOSS_HOME\server/ecoemos/lib/
            Server Config: $JBOSS_HOME\server/ecoemos/conf/
            Server Home: $JBOSS_HOME\server/ecoemos/
            Server Data: $JBOSS_HOME\server/ecoemos/data/
            Server Log: $JBOSS_HOME\server/ecoemos/log/
            Server Temp: $JBOSS_HOME\server/ecoemos/tmp/
    10:51:58,923 INFO  [AbstractServer] Starting: JBossAS [6.0.0.Final "Neo"]
    10:52:00,501 INFO  [ServerInfo] Java version: 1.6.0_21,Sun Microsystems Inc.
    10:52:00,501 INFO  [ServerInfo] Java Runtime: Java(TM) SE Runtime Environment (build 1.6.0_21-b07)
    10:52:00,501 INFO  [ServerInfo] Java VM: Java HotSpot(TM) Server VM 17.0-b17,Sun Microsystems Inc.
    10:52:00,501 INFO  [ServerInfo] OS-System: Windows XP 5.1,x86
    10:52:00,501 INFO  [ServerInfo] VM arguments: -Dprogram.name=run.bat -Xms128M -Xmx512M -XX:MaxPermSize=256M -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Dorg.jboss.resolver.warning=true -javaagent:sizeOf.jar -Djava.endorsed.dirs=D:\Dev\Programs\Servers\JBoss\jboss
    -6.0.0.Final\lib\endorsed
    10:52:00,548 INFO  [JMXKernel] Legacy JMX core initial
    

    I have a button in a JSF page that when is pressed, call a manage bean to meassure the size of the HttpSession object, but unfortunately i allways get the famous InstrumentationisNullException

    2011-12-02 10:45:51,095 SCHWERWIEGEND [javax.enterprise.resource.webcontainer.jsf.context] (http-127.0.0.1-8080-1) java.lang.IllegalStateException: Instrumentation is null: javax.faces.event.AbortProcessingException: java.lang.IllegalStateException: Instrumentation is null
        at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:178) [:2.0.3-]
        at javax.faces.event.ActionEvent.processListener(ActionEvent.java:84) [:2.0.3-]
        at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:773) [:2.0.3-]
        at javax.faces.component.UICommand.broadcast(UICommand.java:296) [:2.0.3-]
        at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:781) [:2.0.3-]
        at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1246) [:2.0.3-]
        at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:77) [:2.0.3-]
        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97) [:2.0.3-]
        at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:114) [:2.0.3-]
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:308) [:2.0.3-]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:324) [:6.0.0.Final]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.0.0.Final]
        at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:67) [:6.0.0.Final]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:274) [:6.0.0.Final]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.0.0.Final]
        at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:118) [:]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:274) [:6.0.0.Final]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.0.0.Final]
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [:6.0.0.Final]
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) [:6.0.0.Final]
        at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:181) [:6.0.0.Final]
        at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.event(CatalinaContext.java:285) [:1.1.0.Final]
        at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.invoke(CatalinaContext.java:261) [:1.1.0.Final]
        at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:88) [:6.0.0.Final]
        at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:100) [:6.0.0.Final]
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) [:6.0.0.Final]
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [:6.0.0.Final]
        at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158) [:6.0.0.Final]
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [:6.0.0.Final]
        at org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.invoke(ActiveRequestResponseCacheValve.java:53) [:6.0.0.Final]
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [:6.0.0.Final]
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [:6.0.0.Final]
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:654) [:6.0.0.Final]
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951) [:6.0.0.Final]
        at java.lang.Thread.run(Thread.java:619) [:1.6.0_21]
    Caused by: java.lang.IllegalStateException: Instrumentation is null
        at net.sourceforge.sizeof.SizeOf.sizeOf(SizeOf.java:59) [:]
        at net.sourceforge.sizeof.SizeOf.deepSizeOf(SizeOf.java:145) [:]
        at net.sourceforge.sizeof.SizeOf.deepSizeOf(SizeOf.java:102) [:]
        at session.backing.showdata.TestSessionBean.invalidate(TestSessionBean.java:111) [:]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_21]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_21]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_21]
        at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_21]
        at org.apache.el.parser.AstValue.invoke(AstValue.java:196) [:6.0.0.Final]
        at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276) [:6.0.0.Final]
        at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:43) [:6.0.0.Final]
        at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:56) [:6.0.0.Final]
        at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:43) [:6.0.0.Final]
        at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:56) [:6.0.0.Final]
        at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:149) [:2.0.3-]
        ... 34
    

    more

    just for the record, my actionListener code

    public void meassure()  {
            // invalidate the session
            System.out.println("SessionID session " + this.getSessionID());
            System.out.println("Size of session with method 222"+SizeOf.deepSizeOf(currentSession()));
        }
    

    And yes, the .jar is in my classpath of the project ( I have even copied the jar file to the WEB-INF/lib , the jboss bin folder and more places just to try)

    I am kind of desperate here, I think I am doing everything ok… what can be my problem?

    Any help would be highly appreciated ! Thanks in advance.

    Josete.

     
    • malayali
      malayali
      2014-02-04

      Add the sizeOf.jar in BootStrap entries under classpath.
      Go to Run Configurations - > ClassPath -> Bootstrap Entries -> add the jar here.
      Make sure your VM arguments have the -javaagent:/Pathof jar also.
      Hope this helps.

       

  • Anonymous
    2011-12-20

    Thank you for the useful tools. It's good to use in web application(JBoss). But I don't know how to use in a java application in Eclipse. It add th argument: -javaagent:<path to>/SizeOf.jar to Run Configuration. But a error shows "Unrecognized option: -javaagent". The famouse Exception(Instrumentation is null)  will happen if I don't add the argumnet.I searched this error on google and this many forums, but I failed. Anybody help me?
    my email is andyliao1019@gmail.com Thank you again!