title: How to estimate the memory size of data structures/variables in Java?
body: <p>I'm doing a project for a class where I'm supposed to implement the algorithms described in a research paper and run the experiments described in the paper. The paper is related to shortest-path queries, so I'm using the <a href="http://jung.sourceforge.net/" rel="nofollow">JUNG</a> library; the paper and the datasets used for the experiments are found <a href="http://dbis.informatik.uni-freiburg.de/index.php?project=TEDI" rel="nofollow">here</a>.</p>
  
  <p>Anyway part of the experiments involves comparing the memory required for the data structures used by the algorithm (a tree derived from the original graph and some info on the shortest paths) to that used by data structures in other algorithms when they're run on the same graph.  The paper's author wrote the code in C++, but my prof let us choose which language to use for this project so I chose Java as I've used it a lot more and therefore code faster in it... But now I'm not sure how to figure out this memory usage thing.</p>
  
  <p>I found a few questions asking similar questions but several were old (4 or 5 years) and others didn't seem to be asking quite the same question; they were calculating the size of structures that wouldn't change.  So I'm hoping someone can point me to an algorithm, method, or even better a library that would give a good estimate for this.  I don't think it needs to be exact, but I need some sort of estimate at least.</p>