Reputation: 793
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 JUNG library; the paper and the datasets used for the experiments are found here.
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.
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.
Upvotes: 1
Views: 1351
Reputation: 42050
I think that depends of implementation of Java Virtual Machine. In the document http://java.sun.com/docs/books/jni/download/jni.pdf or in http://en.wikipedia.org/wiki/Java_Native_Interface the types mapping to C++ to Java.
By example,
a java boolean type is unsigned char jboolean unsigned 8 bits
Upvotes: 0
Reputation: 76261
You want to look at various SizeOf implementations:
and here: http://www.javaworld.com/javaworld/javaqa/2003-12/02-qa-1226-sizeof.html (although this is designed for static size rather than runtime size)
However, this question seems to have a better answer.
Upvotes: 1