• Post Reply Bookmark Topic Watch Topic
  • New Topic

Memory allocation  RSS feed

 
James Tharakan
Ranch Hand
Posts: 580
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


In the above given code, where a class has no data members, How much memory is allocated for the object?? What happens after the statement in the main method is executed???
How to find out the amount of memory present in the heap memory??
 
fred rosenberger
lowercase baba
Bartender
Posts: 12563
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
generally speaking, you don't know, and you don't care. As i understand it, the size can be dependent on some of the decisions made by the folks who wrote the specific JVM being run. So, you can write your code, run it on a windows box and your object will need X bytes of memory, then run the same bytecode on a Mac and it will use Y bytes of memory.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!