• Post Reply Bookmark Topic Watch Topic
  • New Topic

Regarding Memory Allocation  RSS feed

 
Keshava murthy S
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when it comes to primitives jvm allocates 4 bytes for integers, 2 byte for characters, and for boolean it's JVM dependent. When it comes To objects the memory allocated depends upon the number and type of the instance variables.
Now my question is i have a class which does not contain any instance variables and methods, So if i create an object of such a class how much memory gets allocated for that object?

class A{

}

class B{

public static void main(String args[]){

A x=new A();
}
}

How much is the memory allocated for object of class A which is being reffered by variable x?
 
SuryaNarayana Nellepalli
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Memory allocated would depend on JVM. Memory would be required for Book-keeping purposes like Monitor associated with the Object
 
Keshava murthy S
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!