So I have this method, written in Java:
public void myMethod(int y){
int x = 5 + y;
doSomething(x);
}
And assume my application calls this a lot of times..
When running the compiled code for this method on Java Virtual Machine, JVM will first interpret the method. Then after some time it will decide to compile it to machine language if I understand correctly.
At this point,
Will it be overwritten by the machine code in the memory? If it is overwritten, how will the issue of the size difference solved? If it is written to some other place in memory, will the bytecode loaded into memory freed or not? And also, if both bytecode and the jit compiled code is in the memory, when the application hits this method again, how does JVM decide to execute the jit compiled code instead of byte code?
See Question&Answers more detail:os