There is no standard way to do this. In fact, there is really no special way to weigh an object, considering it not just primitives. One way is to serialize the object into an array of bytes and accept it as an indicator of size.
An option would be to use a profiler such as YourKit , which takes a pretty good hit when calculating the saved link size.
Maybe the provider API is for this, since most SessionManager should serialize session data for replication and storage.
source share