In Linux, when memory is requested (using calloc / malloc), if a contiguous block of the requested size is not available does the kernel map multiple separate pieces of memory into one single virtual block and hand it over to the application or is it allocated on disk? If it is allocated on disk, when a large enough block becomes
Tag: memory-management
SIZE command in UNIX
The following is my C file: It contains only return statement. But if I use the size command, it shows the output like this: Even though my program does not contain any global variable, or undeclared data. But, the output shows data segment have 252 and the bss have 8 bytes. So, why the output is like this? what is
Host testing C program with hard coded memory addresses
We will write functional/unit tests for C code. This C program will be run as embedded software. However we need to run tests on a Linux environment. The problem is that parts of the code under test looks like this: my_addresses.h: my_code.c Obviously, this will not run so well on Linux host environment. Is there some way we can work
How is RAM and Heap Space allocated for a linux/unix command?
So when I execute a linux command, say a cat command for this example, on a server with 128 GB of RAM, assuming none of this RAM is currently in use, all is free. (I realize this will never happen, but that’s why it’s an example) 1) Would this command then be executed with a heap space of all 128
Initialization of number of free pages in each order in a memory zone
I am going through the memory initialization code in linux kernel, and I can see the number of free pages for each order and migration type for the each memory zone in a memory node is set to 0. I am not able to figure out how the list is set to the proper state, as in which order has
Are the load address is common for all the C programs in linux?
Let’s say I have a prog1.c which is build as prog1.out. In prog1.out there is a linker information that will tell where the elf will be loaded. These addresses will be a virtual addresses. The loader will look for these information’s and a launch this as a process. Each section like DS,BSS will be loaded on the virtual address as
Are mlock()-ed pages static, or can they be moved in physical RAM?
According the the mlock() man page: All pages that contain a part of the specified address range are guaranteed to be resident in RAM when the call returns successfully; the pages are guaranteed to stay in RAM until later unlocked. Does this also guarantee that the physical address of these pages is constant throughout their lifetime, or until unlocked? If
High mem in arm Architecture
High memory (highmem) is used when the size of physical memory approaches or exceeds the maximum size of virtual memory. The traditional split for architectures using this approach is 3:1, 3GiB for userspace and the top 1GiB for kernel space. This means kernel can at most map 1 GiB of physical memory. In mobile devices average physical memory present is
Linux Kernel Memory Management Paging Levels
I’m reading through the book “Understanding Linux Kernel” by Bovet and Cesati. In the second chapter, under “Paging in Linux” the author mentions how Page Middle and Upper Directories are eliminated with 32 architectures not having PAE enabled. I’m having trouble following what the author means. They have been loose in their treatment and does not make a whole lot
using electric fence in a c++ program
I’ve been experimenting with Electric Fence lately and I can’t figure out how to use it with c++ code. Here’s an example: I compiled it with And I don’t see Electric Fence banner at the start and can’t find EF symbols in the executable (using nm command). But if I modify a program like so: everything is good – EF