Herzl Regev said:
What happens in the RAM if I try to open too many processes? Is there a
stage
that Windows will refuse to open more processes, or will it start to run
slowly? Will there be an error message? Particularly, "virtual memory too
Hi Herzl,
Is this a hypothetical question? Or are you actually seeing a
capacity-related error message?
The number of processes, qua *processes*, that can be created by Windows XP
is limited only by the number of available process handles. I don't recall
off-hand the maximum number, but it is extremely large - maybe 64K or else
2^32.
However, the practical limit will not be the number of processes, as such;
but rather the resources which are consumed by those processes. If they are
GUI procs, they will allocate from the (finite) desktop heap, and hence, are
more limited than processes which run with no UI at all.
Also recall that the primary scheduling unit on Windows is not the process,
but the Thread. Windows is much more likely to hit exhaustion barriers
creating threads, than creating processes - in other words, 2 processes each
with 1,000 threads will bring Windows to its knees, long before (say) 500
processes, each running 2 or 3 threads each. By default, the Windows linker
assigns 1 MB of stack memory to each thread. If you have 2,000 threads, that
gives you 2GB of memory - the maximum which can be addressed in User Mode on
a 32-bit operating system.
As to the question of RAM ... this comes back to the old dichotomy between
REAL memory and VIRTUAL memory. Windows NT (including 2K, XP and Vista) is a
Virtual Memory operating system. On 32-bit Windows, every process has 4GB of
Virtual Memory, bifurcated between User Mode (2GB) and Kernel Mode (also
2GB - the kernel mode space is shared between all processes and threads). It
is the job of the Memory Manager to *map* those virtual addresses onto some
device - such as semiconductor memory (RAM), 4k-sized pages of disk space (a
page file), or some other, more exotic memory device. Processes or threads
themselves have little awareness of RAM; usually they only see virtual
memory addresses. Most PCs only have real memory (RAM) and paging files. If
the number of allocated virtual memory addresses exceeds the available pages
in the backing store, then you will see the "Virtual Memory too low"
message. If there is disk space available, one way to fix this is to
increase the size of the paging files. But if a process has allocated all
available virtual memory addresses (2GB, on a 32-bit system) it doesn't
matter how big your page files are - no more memory can be allocated.
Memory management can be a complex subject and not always amenable to brief
newsgroups answers. So I guess the main question is: is this a theoretical
question? Or are you seeing a capacity planning challenge which you need to
resolve?
For general background on Windows memory management, the best resource is
Chapter 7 of Solomon and Russinovich "Microsoft Windows Internals",
Microsoft Press 2004, ISBN 0-7356-1917-4.
Hope it helps,
Andrew