why, linux, why?!?!?!?

I have been debugging my C application for almost 5 hours, trying to see where I forgot to free the memory.
It is basically my implementation of FTP protocol. When I have a lot of concurrent clients, memory usage goes up, because the files that I have are compressed and can only be decompressed while being completely loaded into memory. So when I have a lot of clients, memory usage goes up by a lot. But it never goes down, even after they disconnect!!
And NOW I realized that what Linux does is that if memory is being allocated and freed often, IT JUST KEEPS THE ALLOCATED BLOCK! It NEVER frees it!! If that thought didn't cross my mind, how THE FRICK would I even guess that?!?

Black Rifle Cuck Company, Conservative Humor Shirt $21.68

UFOs Are A Psyop Shirt $21.68

Black Rifle Cuck Company, Conservative Humor Shirt $21.68

  1. 1 month ago
    Anonymous

    should have just asked linus

  2. 1 month ago
    Anonymous

    i'm not a programmer but isn't memory allocation and deallocation- one of distinct "features" of C and what's it is often criticized for? how is it a linux problem?

    • 1 month ago
      Anonymous

      It is a linux problem because it IGNORES the deallocation, making it seem like my program is faulty when it ISN'T

      • 1 month ago
        Anonymous

        this is serious accusation against GNU/Linux, have you brought it to their attention?

        • 1 month ago
          Anonymous

          No, not yet because it could also be glibc's fault. Even thought glibc is GNU so part of same OS (GNU/Linux)
          However it seems unlikely that language runtime would manage things so autistically.

      • 1 month ago
        Anonymous

        >And NOW I realized that what Linux does is that if memory is being allocated and freed often, IT JUST KEEPS THE ALLOCATED BLOCK! It NEVER frees it!!
        Depends on the malloc implementation. most of them keep several pools in userspace so they don't have to ask the kernel for every tiny allocation.
        This isn't linux-specific. Almost every libc implementation for every OS does this. The exact strategies and amounts vary though.

        >It is a linux problem because it IGNORES the deallocation, making it seem like my program is faulty when it ISN'T
        You're chasing the wrong metric. If you want to check for memory leaks use something like valgrind or the allocator's debugging interface. Not RSS or whatever you're looking at.

        • 1 month ago
          Anonymous

          >You're chasing the wrong metric. If you want to check for memory leaks use something like valgrind or the allocator's debugging interface. Not RSS or whatever you're looking at.
          I have a bash script which uses ps periodically to output memory usage

          • 1 month ago
            Anonymous

            yes, that's the wrong metric.

      • 1 month ago
        Anonymous

        if you use malloc and free, then these are user library functions, not system calls
        so you'd need to know how they do that heap management internally

        they probably use mmap and munmap to request memory from the OS
        and the latter syscall should make the memory available right away

  3. 1 month ago
    Anonymous

    >If that thought didn't cross my mind

    but it did cross your mind.....

  4. 1 month ago
    Anonymous

    That's the language runtime not the kernel moron.

    • 1 month ago
      Anonymous

      trains is a hard job!

  5. 1 month ago
    Anonymous

    >because the files that I have are compressed and can only be decompressed while being completely loaded into memory
    all relevant compression algorithms support streaming, zoom zoom

    • 1 month ago
      Anonymous

      not all implementations do, moron. especially those in C. I was lucky enough to find one that didn't outright take an output filename as an argument

      • 1 month ago
        Anonymous

        lol you're too moronic to use the official implementation that does support streaming so you chose someone's toy example that they made for the purpose of learning how that compression algorithm works

        • 1 month ago
          Anonymous

          stop being a homosexual and humble down already

          • 1 month ago
            Anonymous

            i am returning the same energy that you came in here with

  6. 1 month ago
    Anonymous

    >has skill issue
    choose your path:
    - blame the operating system
    - blame the compiler

    • 1 month ago
      Anonymous

      >choose your path:
      >- blame the operating system
      >- blame the compiler
      you can also blame libc

  7. 1 month ago
    Anonymous

    figure it out.

    valgrind --leak-check=full binaryname

Your email address will not be published. Required fields are marked *