Running this piece of code is supposed to cause program break to increase by about malloc_counts * _SC_PAGESIZE
instead I get fixed program break each time, so why is this. malloc is supposed to call brk
or sbrk
which itself round up size passed to next page (with some extra work). So what's happening ?
#include <stdio.h>
#include <malloc.h>
#include <unistd.h>
int main(){
const long malloc_counts = 10;
printf("PAGE SIZE: %ld\n", sysconf(_SC_PAGESIZE));
void* allocated_pool[malloc_counts];
for(int counter=0; counter < malloc_counts; counter++)
{
printf("program brk: %p\n",sbrk(0));
allocated_pool[counter] = malloc(127*4096);
}
}