Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can I get the History of an object or trace an Object

I have a requirement, where support in my application a lot of processing is happening, at some point of time an exception occrured, due to an object. Now I would like to know the whole history of that object. I mean whatever happened with that object over the period of time since the application has started.

Is this peeping into this history of Object possible thru anyway using JMX or anything else ?

Thanks

like image 486
user1448281 Avatar asked Dec 29 '25 00:12

user1448281


1 Answers

In one word: No

With a few more words:

The JVM does not keep any history on any object past its current state, except for very little information related to garbage collection and perhaps some method call metrics needed for the HotSpot optimizer. Doing otherwise would imply a huge processing and memory overhead. There is also the question of granularity; do you log field changes only? Every method call? Every CPU instruction during a method call? The JVM simply takes the easy way out and does none of the above.

You have to isolate the class and/or specific instance of that object and log any operation that you need on your own. You will probably have to do that manually - I have yet to find a bytecode instrumentation library that would allow me to insert logging code at runtime...

Alternatively, you might be able to use an instrumenting profiler, but be prepared for a huge performance drop when doing that.

like image 50
thkala Avatar answered Dec 31 '25 17:12

thkala