I know that local variables and paramters of methods live in stack, but I not able to figure out where does actually methods live in case of Java?
If I declare any Thread object like:
Thread t=new Thread();
t.start();
So it means I’ve created a separate calling of methods apart from main method. What does it mean? Does it mean calling of separate sequence of methods over Stack memory? Am I right?
Each thread is allocated its own stack.
This article has a good introduction to the memory separation within a Java process.
I’ve seen many scenarios where clients have implemented hugely threaded servers on the basis that each thread does very little, and they run into problems with memory. That’s because each thread is allocated its own stack, and this (obviously) adds up. I think the default value is 512k per thread, but I’ve not found a canonical source for that.