Heap / Stack and multiple processes
Say I have two process p1,p2 runnning as a part of my application.
Say p1 is running initially executing function f1() and then f1() calls f2().With the invocation of f2() process p2 starts excuting
What I want to confirm is it that :- 1)Do we have seperate stack for different process?
2)Do we have seperate heap for different process? or do different process share same heap?
3)As we know that for a 32 bit OS do for every process the size of vir开发者_如何学编程tual memory is 4GB .So is it that for every process which has 4GB as virtual memory this 4GB is partitioned into heap,stack,text,data
Thanks.
1) Yes, each process gets its own stack.
2) Yes, each process gets its own heap.
3) I don't think you get the whole 4GB. Some of it is reserved for kernel stuff.
- The virtual memory for a process will be different from other process.
- Every process will get 4GB of virtual address space ( in 32 bit windows machine) and out of which you can use 2GB of user space ( remaining is for kernel). For stack, heap, static data storage and even loading the DLLs. (This is 3GB if you use large address space)
- Every process will get separate heap, stack independent of other process.
There are other limitations to consider in Java too, such as only being able to address arrays using Integer.MAX_VALUE at most. This limits you to about 2GB in a lot of areas relating to memory.
精彩评论