Reputation:
Local variables gets placed in stack when method is called and when JVM halts without completing the method, will the local variable still remain on the stack?
Example:
void Method() {
int a=2;
System.exit(0);
Foo f=new Foo();
}
Upvotes: 2
Views: 88
Reputation: 310909
There is no stack after the process exits, so there are certainly no local variables left on it, or anything else either.
Upvotes: 0
Reputation: 284826
The Java-level stack will be gone, and the OS will free the memory. However, nothing is going to actually zero it out so the stack variables will remain in that sense.
Upvotes: 0
Reputation: 12538
When you restart the vm you will have fresh values and a fresh stack. Anything after a System.exit(0) won't be called.
Upvotes: 0
Reputation: 19797
No. After the System.exit(0)
the system will clean-up the mess.
Upvotes: 2