memory-overcommitment

new[] doesn't decrease available memory until populated

狂风中的少年 提交于 2021-02-08 12:24:09
问题 This is in C++ on CentOS 64bit using G++ 4.1.2. We're writing a test application to load up the memory usage on a system by n Gigabytes. The idea being that the overall system load gets monitored through SNMP etc. So this is just a way of exercising the monitoring. What we've seen however is that simply doing: char* p = new char[1000000000]; doesn't affect the memory used as shown in either top or free -m The memory allocation only seems to become "real" once the memory is written to: memcpy

Malloc on linux without overcommitting

心已入冬 提交于 2019-12-23 09:58:03
问题 How can I allocate memory on Linux without overcommitting, so that malloc actually returns NULL if no memory is available and the process doesn't randomly crash on access? My understanding of how malloc works: The allocator checks the freelist if there is free memory. If yes, the memory is allocated. If no, new pages are allocated from the kernel. This would be where overcommit can happen. Then the new memory is returned. So if there is a way to get memory from the kernel that is immediately

fork() failing with Out of memory error

守給你的承諾、 提交于 2019-12-18 13:19:09
问题 The parent process fails with errno=12(Out of memory) when it tries to fork a child. The parent process runs on Linux 3.0 kernel - SLES 11. At the point of forking the child, the parent process has already used up around 70% of the RAM(180GB/256GB). Is there any workaround for this problem? The application is written in C++, compiled with g++ 4.6.3. 回答1: Maybe virtual memory over commit is prevented in your system. If it is prevented, then the virtual memory can not be bigger than sizeof

fork() failing with Out of memory error

浪尽此生 提交于 2019-11-30 09:13:51
The parent process fails with errno=12(Out of memory) when it tries to fork a child. The parent process runs on Linux 3.0 kernel - SLES 11. At the point of forking the child, the parent process has already used up around 70% of the RAM(180GB/256GB). Is there any workaround for this problem? The application is written in C++, compiled with g++ 4.6.3. Maybe virtual memory over commit is prevented in your system. If it is prevented, then the virtual memory can not be bigger than sizeof physical RAM + swap. If it is allowed, then virtual memory can be bigger than RAM+swap. When your process forks,