public jvmtiError GetObjectSize(JvmVirtualMachineRemoteHandle virtualMachine, JvmObjectRemoteHandle @object, out long size) { JavaVM machine = JavaVM.GetInstance(virtualMachine); long sizeResult = 0; jvmtiError result = jvmtiError.Internal; machine.InvokeOnJvmThread( (environment) => { jvmtiInterface rawInterface = environment.RawInterface; result = rawInterface.GetObjectSize(environment.Handle, @object, out sizeResult); }); size = sizeResult; return(result); }