I have written this code in C which reads a very large collection of text files and does some processing. The problem with this code is that there are memory leaks which I am not able to figure out as to where the problem is.
I learned that on Linux the glibc’s malloc() uses mmap() for very big chunk of memories and brk() is used for small allocations.
We know for every process, it has 4G virtual memory on a 32bit machine.
since virtual memory is not physical memory, why don't operating system allocate all it's virtual memory to it, but set a "program break" to limit it's heap space?
Even if the operating system allocate all the 4G virtual memory to a process, only when the process access an address that not mapped into physical memo
I am trying to use the mamp() functionality provided in linux-kernel.
As we call mmap() in user-space we try to map virtual memory area of user-space process to the memory in the kernel-space.
the definition of mamp() inside kernel is done in my kernel module which try to allocate some memory in pages & maps it during mmap system call.
I'm doing some raw socket scripting in C. Everything works fine.
However, I monitored the memory using top, and it shows that the memory used by my script is increasing over time.
I don't have that many mallocs (maybe a couple), but lots of pointers.
I have an application that reserves a contiguous memory block using VirtualAllocEx on Windows with the MEM_RESERVE flag. This reserves a virtual memory block, but does not back it with a physical page or page file chunk.
I am debugging one issue where a same program behaves differently on different Linux boxes (all 2.6 kernels). Basically on some linux box, mmap() of 16MB always succeeds, but on other linux box the same mmap() would fail with "ENOMEM".
I checked /proc//maps and saw the virtual memory map on different linux boxes are quite different.
Running perl script in solaris 10 machine. Know the RAM Size is 25 GB. Have two queries.
Normally How much RAM memory a solaris process is allocated. Is it a default value assigned to any script or process. where it can be set? How do i determine how much max static array size can i have and how much dynamic memory can i allocate?
I'm trying to simulate memory exaustion. So here is what I'm thinking:
turn off over commiting.
reduce the available heap so that the memory exaustion can happen quicker.
Run the program under test.
My question is w.r.t 2: is there a trick that reduce the heap size that kernel will allocate?