If I have:
int c[] = new int[10];
and
int a[][] = new int[2][3];
and in generally
an n*m*..*j array
how can I calculate the real memory usage considering also the references variables?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you want an accurate answer, you can’t. At least not in any easy way. This thread explains more.
The trouble with Bragaadeesh’s and Bakkal’s answers are that they ignore overhead. Each array also stores things like the number of dimensions it has, how long it is and some stuff the garbage collector uses.
For a simple estimate, you should be fine by using the calculations from the other answers and adding 100-200 bytes.