• Post Reply Bookmark Topic Watch Topic
  • New Topic

Array Memory allocation

 
Cheenath Ajay
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How array memory allocation is managed in Java?
In the sense, I have a Object two dimensional array initialized with say obeject[10][10].

How much will be memory allocated for this initialization.

The reason is in the array initialized, my program is going to insert Object instance into some of the array indexes. That means some of the array indexes will be null/empty. How expensive are those empty/null arrays?

Thanks in advance,
-Ajay
 
Ireneusz Kordal
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

it depends on platform and architecture of particular JVM implementation.
On 32-bit platforms object reference has usually 8 bytes, but on 64-bit could sometimes have 16-bytes, on mobile devices could have 4 bytes etc.
Read this article:
http://www.javaworld.com/javaworld/javatips/jw-javatip130.html?page=1
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!