• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Array Memory allocation

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic