2

In Java, on a 32 bit OS, I store 5736 int[] arrays containing 54759118 ints. If each int primitive takes 4 bytes, then I will get minimum 54759118 * 4 = 219036472 bytes ~ 220 megabytes. Since I have 5736 references to int[] objects, what will be an overhead of storing those references?

1 Answer 1

2

Each 32-bit pointer in Java allocates ~4 bytes. Hence, it will be 5736 * 4 = 22944 bytes

Sign up to request clarification or add additional context in comments.

5 Comments

There are only 5736 references
@Heuster ups :)) Thank you very much, its my inattention.
Thank you, so this will be an overhead size, 23 megabytes? Is something spent on storing say length of array, or only ints as contents and array references are stored?
@SophieSperner 4 bytes per an array reference. It doesn't depend on array's length. And it is only 22 kilobytes, not megabytes :)
Just a comment aside: by the link at the end they say that int[1024] takes 4112 bytes. If you use our logic: 1024 * 4 + 4 (ref) = 4100 < 4112 consequently 12 bytes are stored for something else. Link: vanillajava.blogspot.ie/2011/07/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.