The initial heap size allocated for a C ++ program on UNIX

What is the initial heap size normally allocated for a C ++ program running on a UNIX-based OS?

How does the g ++ compiler solve this, if at all, should it play a role in this regard?

+3
source share
4 answers

For C ++, regardless of the platform, the heap almost always expands dynamically, requesting the OS for more memory as needed. On some embedded platforms or on some very old platforms this may not be true, but then you probably have a really good idea how much heap you have due to the nature of the environment.

Unix . Unix .

, , - , , , . , , , .

Unix , . getrlimit. RLIMIT_AS. , , .

, , . mmap, .

, , , , . , .

, Unix . , , . , , . , -.

, , , .

+5

, .

, .

GC. C ++ , , . , .

+4

, . , .

:

 cat /proc/meminfo  | grep CommitLimit 
 CommitLimit:    498080 kB

CommitLimit :     CommitLimit = ('vm.overcommit_ratio' * Physical RAM) + Swap

, swap , overcommit_ratio, . overcommit_ratio by:

sysctl -w vm.overcommit_ratio=60

, , ( 2 'vm.overcommit_memory').. :

 sysctl -w vm.overcommit_memory=2

​​document, .

0

while (true). "cat/proc/{pid}/maps" .

0

Source: https://habr.com/ru/post/1719858/


All Articles