Partly out of curiosity - we want to know what happens in our application - and partly because we need to find some potential issues in our code, I like to track some general values during runtime of our web applications. This includes especially the allocated memory of certain object graphs.
Our applications keeps some data permanently in memory to have it reliable available. This can sum up to several GB of memory, while other applications that do almost the same stuff only allocate one or two.
Due to required performance we cannot attach memory profilers during runtime. So it would be great to analyze an object graph at runtime to print out which parts of the data are so big in some cases and which are not so big. This would help us a lot to better understand what happens with the data and potentially optimize the behavior of our applications.
Object graph means, starting from a certain object, measuring its size in memory, recursively following all referenced objects through all properties, fields, lists with all their elements etc. and adding their corresponding size until we have the information how much memory is used by this object and all related objects.
Actually, the question I would like to have an answer for is: When I just release the last reference to this anchor object, how much would the GC be able to free up when cleaning this object graph with the next run?