Reputation: 3924
I have a class and I'd like to see which sub-objects occupy the most space when object from this class is serialized. Is there any nice tool/way to do it, except from looking at the code and analyzing it manually?
For example I would like the tool to say "member a occupies 20%, b 30% and member c occupies 50%".
Thanks
P.S. I found some related questions, but didn't find answer to my specific question there.
Upvotes: 8
Views: 4690
Reputation: 26200
DbVisualizer provides Serialized Java Objects Viewer.
There also a serialysis
tool mentioned at Does Eclipse have an editor/viewer for java serialized files?
Upvotes: 1
Reputation: 5220
Well, I've never heard about such tool. But I think there is some relation between object size in memory and serialized object size. So you can try using a profiler: VisualVM, which is included in JDK or my favorite YourKit Profiler.
Upvotes: 0
Reputation: 3560
The only relatively fast way to count the size of the object is to first write the whole object, count the usage (for example, write to a ByteArrayOutputStream) and then write each object that is referred to.
There are a couple of this to take into account:
For the description of the protocol, read this description.
Upvotes: 1