Memory allocation of program without any allocation syscalls

101 views Asked by At

I am currently working on a C program in Debian. This program at first allocates several gigabytes of memory. the problem is that after the startup of the program, still it is allocating memory. I checked and there is no malloc or calloc or etc. in the main loop of the program. I have checked the memory with the RES column in the htop command. then I decided to check the memory syscalls of the program with strace. I attached strace after program startup using this command:

strace -c -f -e trace=memory -p $(pidof myprogram)

Here is the result:

% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
100.00    0.000311           0     10392           mprotect
------ ----------- ----------- --------- --------- ----------------
100.00    0.000311                 10392           total

So it is clear that there is no brk or mmap syscalls that can allocate memory.

Here is the list of all syscals:

% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 33.00    1.446748        6156       235        67 futex
 32.41    1.420658        8456       168           poll
 17.35    0.760549          31     24459           nanosleep
 16.24    0.712000       44500        16           select
  1.00    0.044000        7333         6         2 restart_syscall
  0.00    0.000000           0        80        40 read
  0.00    0.000000           0        40           write
  0.00    0.000000           0       184           mprotect
  0.00    0.000000           0        33           rt_sigprocmask
  0.00    0.000000           0        21           sendto
  0.00    0.000000           0        47           sendmsg
  0.00    0.000000           0       138        44 recvmsg
  0.00    0.000000           0         7           gettid
------ ----------- ----------- --------- --------- ----------------
100.00    4.383955                 25434       153 total

Do you have any idea why is memory allocated?

0

There are 0 answers