what's the overhead when allocating objects/arrays in Java?
Posted
by
Gnijuohz
on Programmers
See other posts from Programmers
or by Gnijuohz
Published on 2012-08-28T03:15:59Z
Indexed on
2012/08/28
3:51 UTC
Read the original article
Hit count: 211
How many bytes an array occupies in Java? Assume It's a 64bit machine and also assume there are N elements in an array, so all these elements would take up 2*N, 4*N or 8*N bytes for different types of array.
And a lecture in Coursera says that it would occupy 2*N+24, 4*N+24 or 8*N+24 bytes for a N element array and the 24 byte is called overhead
, but didn't explain it.
Also objects have overheads
, which is 16 bytes.
What exactly are these overheads
? Also, do these overheads
only exist in Java? How about C, C++ and Python?
© Programmers or respective owner