Memory occupation of instance objects
Hi everyone,
I have a question about creation of Java instance objects.
I know that every Java object occupies some quantity of memory, depending on how many fileds have (and how big in memory are).
I want to know if a Class which contains a great number of methods (also not used) is bigger in memory than one exactly the same, but with a smaller number of methods.
For example:
publicclass Example1{
pulicint myInt = -1;
public Example1(int myInt){
this.myInt = myInt;
}
publicvoid setUp (){
.....
}
publicint getInt(){
return myInt;
}
publicvoid setInt(myInt){
this.myInt = myInt;
}
}
publicclass Example2{
pulicint myInt = -1;
public Example2(int myInt){
this.myInt = myInt;
}
publicvoid setUp (){
.....
}
}
I want to know if Example2, when created with anew, is smaller in memory than class Example1.
I don't refer to Permanent memory (meta-rapresentation of Classes and their methods)... in this case (speaking about Permanent memory) Example2 is "cheaper" than Example1.
I instead refer to memory allocated from every new instance of class Example1 and Example2.
Thank you very much all in advance.
Diego

