1

I have a JVM running. For 2 different moments in time t0 and t1 I'd like to know how values for all static fields of all classes changed at t1 versus t0.

Solutions I had in mind:

  1. Monitor/debug/profile all static fields write access.
  2. Compare 2 memory snapshots, taken at t0 and t1, to find the diff in field values. I have access to Java VisualVM and YourKit profiler.

I wasn't able to find answers for either of the above.

What is the best way to achieve my goal if possible?

preeze
  • 1,061
  • 1
  • 12
  • 18

1 Answers1

0

With a java debugger, you should be able to set breakpoints on values of fields, so that the debugger breaks whenever the value changes. E.g. the Eclipse java debugger has such a function (Right-click on the field, select "toggle breakpoint").

Edit: If you want more control (e.g. programmatic control), you could run your program using a Btrace script. Those are plain Java programs using a very reduced API, and are hooked into the JVM.

llogiq
  • 13,815
  • 8
  • 40
  • 72
  • IDE debugger was the most obvious thing that I tried first. But with that you need to specify the names of the class and of the field that you want to monitor. In my case I want to monitor all static fields of all classes, and that's why I am not able to manually create all the necessary breakpoints. – preeze Feb 20 '15 at 14:48