I develop software for embedded Linux, and I suffer from a system crash because OOM Killer appears from time to time. Before going beyond that, I would like to solve some confusing problems related to the way the Linux kernel allocates dynamic memory, assuming that / proc / sys / vm / overcommit _memory has 0 and / proc / sys / vm / min _free_kbytes has 712 and does not have swap.
Suppose there is currently physical Linux built-in memory available: 5 MB (5 MB free memory and inaccessible cache or buffer memory) if I write this piece of code:
.....
#define MEGABYTE 1024*1024
.....
.....
void *ptr = NULL;
ptr = (void *) malloc(6*MEGABYTE);
if (!prt)
exit(1);
memset(ptr, 1, MEGABYTE);
.....
I would like to know if, when calling memset, the kernel will try to allocate ~ 6 MB or ~ 1 MB (or min_free_kbytes multiple) in the physical memory space.
9 , 32 . ,
total used free shared buffers
Mem: 23732 14184 9548 0 220
Swap: 0 0 0
Total: 23732 14184 9548
C, , , oom , , , > 6 .
, , oom, , :