There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Myke Enriq wrote:
When exactly is the memory for object a allocated ? What allocates memory for this object ?
The constructor of A is the default:
A(){
super();
}
At what line memory is allocated for a , and how much ?
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
fred rosenberger wrote:Since the JLS doesn't specify how it needs to be done, the answer can vary depending on which exact JVM you are using. If Henry writes one, he may decide to do it HERE, and if I write one, I may decide to do it THERE.
Really, the whole purpose of a high-level language like Java is that you don't know, you don't NEED to know, and you shouldn't care. If knowing the exact instruction set is critical, then you'd be better served by writing your code in assembly or some other low-level language.
Myke Enriq wrote:First I remember that years ago I was asked how much memory was allocated at the creation of a new object of some class with an int and String members. However I do not remember if it was Java or C++.
Myke Enriq wrote:
Secondly , there is a lot of magic in this line: A a = new A(); I still can not say at what moment in time a instanceOf A becomes true , and at what moment of time space is allocated for a.
Myke Enriq wrote:
On a more serious note , I have a feeling it makes a big impact on the way I write code if I actually know what creating a java object means , what default functions and members class A{} has , and when and at how memory for new A() is allocated.
Please tell me where I can search for answers.
Myke Enriq wrote:
But I digress. Please tell me where can I find more information of how JVM creates new objects and allocates memory.
I would very much love to see a diagram of this process , if possible.
He puts the "turd" in "saturday". Speaking of which, have you smelled this tiny ad?
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
|