You are right, the memory of the heap is for the process. However, all processes in the same system allocate memory from the same fixed pool, which is limited by the physical memory of your system plus the page file in virtual memory systems. That is why, if one process is held in memory in which it is not needed, it may starve out of the memory of another process on the same computer.
On systems with virtual memory, this does not necessarily mean that there is not enough memory in other processes: this means that to get more memory for these other processes, switching other processes from memory will be required. This could be your ongoing process or some other process that needs to be replaced.
On systems without virtual memory management, a memory leak in one process will cause other processes to not allocate memory at all.
source share