JVMTI VMObjectAlloc

Keith McGuigan keith.mcguigan at oracle.com
Fri Jun 10 11:28:25 PDT 2011


Forwarding to serviceability-dev (and Bcc'ing hotspot-runtime-dev off).

I personally don't see anything obviously wrong in the code you sent  
but it looks like you've only sent a small fragment of the code and  
the problem could well be somewhere else.  What is the output, and  
what do you expect?  Does it count 6, 600, or 6000, 60000 or what?  Is  
it even close?  What happens when you change the number of iterations  
in the java program?  Are you seeing any other threads calling  
allocation, and if so are you implementing the proper locking for your  
gdata?

--
- Keith

On Jun 10, 2011, at 1:58 PM, Lee Ming wrote:

> 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,gener! ic_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++){
>         &nbs! p;           &n bsp;   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.ou! t.println("alloc");
>             }
>
>     }
>
>    }
>
>  Please let's me know whether i have made any mistake
>
> Thank you
> Bhm



More information about the serviceability-dev mailing list