JVMTI VMObjectAlloc

Lee Ming wonderer_101 at live.com
Fri Jun 10 10:58:08 PDT 2011


Hi, 
I'm doing some test with JVMTI VMObjectAlloc, and it seems like the callback cant catch object allocation properly .e.g: regardless how I tried to allocate new objects in Java program, the agent still report the same number of objects allocated.

This is the source code of the callback

    char *generic_name;
    jvmtiThreadInfo info;
    jvmtiError error;  

    (void)memset(&info, 0, sizeof(info));
    
    error = (*jvmti)->GetClassSignature(jvmti, object_klass,&generic_name,NULL);
    check_jvmti_error(jvmti, error, "can't get class name");
    //printf(generic_name);

    gdata->object_size = gdata->object_size + size;
    gdata->ccount++;

    stdout_message("%d.Object allocated, class: %s\tsize:%d\n",gdata->ccount,generic_name,size);  
     printf("total size now is: %I64d\n",gdata->object_size);
    
    
    error = (*jvmti)->GetThreadInfo(jvmti,thread, &info);
    check_jvmti_error(jvmti, error, "can't get thread info");
    printf("thread name:%s\n",info.name);
    (*jvmti)->Deallocate(jvmti, (unsigned char *) info.name);
    (*env)->DeleteLocalRef(env, info.thread_group);
    (*env)->DeleteLocalRef(env, info.context_class_loader);

And the sample Java test file
    public class Test {
   
    public static void main(String[] args){
          
            for(int i=0; i<10000;i++){
                        Hello h1 = new Hello(1,2);
                        Hello h2 = new Hello(3,4444);
                        Hello h3 = new Hello(3,44);
                        h1.w();
                        h2.w();
                        h3.w();
                        //System.out.println("alloc");
            }
          
    }
    
   }

 Please let's me know whether i have made any mistake

Thank you
Bhm
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/attachments/20110611/51aca482/attachment.html 


More information about the hotspot-runtime-dev mailing list