+ 2

What is the highest size a stack and heap can be in c++?

So I was wondering if 2MB are the highest stack size and whats the highest size a heap can be?

15th May 2019, 4:23 AM
Andy
Andy - avatar
2 Respuestas
+ 5
Famously on 32-bit windows a single process cannot use more than 2GB of RAM; 3GB if you do some fiddling. That is because you can't fit more than ~4 000 000 000 addresses into 32 bits of space, so you have no way to address more than 4GB of RAM. 4GB then is the hard limit, and windows would reserve some of those 4GB itself. By the same logic 2^64 gives you about 18 million terabytes on 64-bit systems per process, so that would currently be the "largest heap size" possible. That being said windows 10 supports 6 terabytes of RAM at most so we won't run into this limit any time soon. (I am not sure if what I'm saying is at all accurate by the way so don't take my word for it)
15th May 2019, 5:23 AM
Schindlabua
Schindlabua - avatar