This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug malloc/21731] Bad malloc heuristic result in 30-40x memory consumption


https://sourceware.org/bugzilla/show_bug.cgi?id=21731

--- Comment #6 from Adhemerval Zanella <adhemerval.zanella at linaro dot org> ---
(In reply to Yichao Yu from comment #5)
> ```
>   system ("cat /proc/self/status | grep -E '^VmRSS'");
> ```
> 
> FWIW, I think this is reading the status of the `cat`.


Right, my mistake here. However fix this:

---
$ cat intercept.c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

void malloc_stats (void)
{
  pid_t pid = getpid ();
  char line[128];
  snprintf (line, 128, "cat /proc/%d/status | grep -E '^VmRSS'", (int) pid);
  system (line);
}
---

does show RSS increase:

$ LD_PRELOAD=./libintercept.so ./malloc
VmRSS:     33220 kB
VmRSS:     33420 kB
VmRSS:     35468 kB
[...]
VmRSS:     61108 kB
VmRSS:     61184 kB
VmRSS:     61184 kB

However it is roughly what valgrind shows as leaked memory:

==18794== LEAK SUMMARY:
==18794==    definitely lost: 54,274,581 bytes in 75,230 blocks
==18794==    indirectly lost: 0 bytes in 0 blocks
==18794==      possibly lost: 65,536 bytes in 1 blocks
==18794==    still reachable: 0 bytes in 0 blocks
==18794==         suppressed: 0 bytes in 0 blocks

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]