Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Maximum size of Java Object

 
victor kamat
Ranch Hand
Posts: 247
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it true that maximum size of a Java Object is 2 giga bytes ?

What if object A contains another object B ?
Is the size of B included in the size of A ?


 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The largest positive int is 2^31 -- i.e., about 2 billion . That places a number of limits on Java objects and code, but really, these are not very significant. What possible use could you have for a 2GB object, anyway? Aside from an array, I can't even conceive of how you'd create one.

To answer your question: that limit affects a single object, not a chain of object references. Each object has its own limit..
 
Henry Wong
author
Marshal
Pie
Posts: 20836
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is the size of B included in the size of A ?


Basically, the reference to B is included in the size of A. So, for each object that your object contains, your object will be 4 bytes (8 bytes for 64 bit JVMs) larger.

Henry
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note that there is no theoretical limit to the size of a Java object - the limit is determined by the particular implementation of the Java specification that you're using.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic