Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

size of an object

 
pradeepta chopra
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how do we find out the size of an object?
somewhere i read that the way is to convert into string and note the length.
but i find a string like @1fee6fc???
now wat does the above string represent??
 
Jelle Klap
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's a bit more involved than that, I'm affraid.
Take a look at this Javaworld article.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15359
39
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The "@1fee6fc" that you see when you call the toString() method of class Object is the hash code of the object in hexadecimal; it does not have anything to do with the size of the object in memory (or the address of the object, as some people think it is).

There is no easy way to find the size of a Java object in memory.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic