• Program uses less memory under Valgrind Massif

    From Frederick Gotham@21:1/5 to All on Thu Jun 3 05:20:51 2021
    I have a Linux program that starts out with one thread, and it uses 88 kB of RAM.

    It then spawns a 2nd thread for a TCP connection, and a 3rd thread for sending digital audio samples to ALSA.

    When the 2nd and 3rd thread start together, the memory usage jumps from 88 kB to 157 MB. I don't know where this extra memory is being allocated.

    So next I run my program under Valgrind Massif, but my program no longer spikes from 88 kB to 157 MB. My program runs fine under Valgrind Massif without any memory spike -- it stays constant at about 88 kB.

    Anyone seen this kind of thing before?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Frederick Gotham@21:1/5 to Frederick Gotham on Thu Jun 3 06:19:58 2021
    On Thursday, June 3, 2021 at 1:20:53 PM UTC+1, Frederick Gotham wrote:
    I have a Linux program that starts out with one thread, and it uses 88 kB of RAM.

    It then spawns a 2nd thread for a TCP connection, and a 3rd thread for sending digital audio samples to ALSA.

    When the 2nd and 3rd thread start together, the memory usage jumps from 88 kB to 157 MB. I don't know where this extra memory is being allocated.

    So next I run my program under Valgrind Massif, but my program no longer spikes from 88 kB to 157 MB. My program runs fine under Valgrind Massif without any memory spike -- it stays constant at about 88 kB.

    Anyone seen this kind of thing before?

    I used 'pmap' just now on the process when it has jumped up to 157 MB, and I see:

    0000007f80021000 65404K ---p [ anon ]
    0000007f88021000 65404K ---p [ anon ]

    There are two allocations of ~64 MB each. I wonder if it's 64 MB for each thread I spawn? I have one guy telling me it's probably glib.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Scott Lurndal@21:1/5 to Frederick Gotham on Thu Jun 3 14:00:32 2021
    Frederick Gotham <cauldwell.thomas@gmail.com> writes:

    I have a Linux program that starts out with one thread, and it uses 88 kB of RAM.

    How do you know that it uses 88kb of RAM? Where did
    you find that number? Is it RSS? VAS? RSS+SWAP?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lew Pitcher@21:1/5 to Frederick Gotham on Thu Jun 3 18:43:53 2021
    On Thu, 03 Jun 2021 05:20:51 -0700, Frederick Gotham wrote:

    I have a Linux program that starts out with one thread, and it uses 88 kB of RAM.
    [snip]
    Anyone seen this kind of thing before?

    You multi-posted your question to comp.lang.c, instead of cross-posting it.
    You can find my reply, such as it is, in comp.lang.c.

    Short answer: Valgrind Massif doesn't account for memory that's directly allocated through naked mmap(2) calls. My guess is that your process has
    some code (either in /your/ code, or in the support logic you invoke)
    that allocates storage directly through mmap(2), and that the ACTUAL
    memory usage DOES NOT vary between the unmonitored run and the Valgrind run.

    --
    Lew Pitcher
    "In Skills, We Trust"

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)