Check available memory in Linux

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
7
down vote

favorite
1












I am writing a Python script which downloads 4K videos and plays them on request. When my device memory goes above 7.2 GB it deletes the video with the least number of views.



Using the free command or top command I can get the memory information. But specifically, how do I get the total memory used? So that I can return this to the Python function to compare with the memory threshold.







share|improve this question


















  • 2




    See also stackoverflow.com/questions/276052/… for other ways to do it in python. In particular, if you need portability across various OSs, the psutil python module seems like the right way to go.
    – Brian Minton
    Aug 8 at 14:11














up vote
7
down vote

favorite
1












I am writing a Python script which downloads 4K videos and plays them on request. When my device memory goes above 7.2 GB it deletes the video with the least number of views.



Using the free command or top command I can get the memory information. But specifically, how do I get the total memory used? So that I can return this to the Python function to compare with the memory threshold.







share|improve this question


















  • 2




    See also stackoverflow.com/questions/276052/… for other ways to do it in python. In particular, if you need portability across various OSs, the psutil python module seems like the right way to go.
    – Brian Minton
    Aug 8 at 14:11












up vote
7
down vote

favorite
1









up vote
7
down vote

favorite
1






1





I am writing a Python script which downloads 4K videos and plays them on request. When my device memory goes above 7.2 GB it deletes the video with the least number of views.



Using the free command or top command I can get the memory information. But specifically, how do I get the total memory used? So that I can return this to the Python function to compare with the memory threshold.







share|improve this question














I am writing a Python script which downloads 4K videos and plays them on request. When my device memory goes above 7.2 GB it deletes the video with the least number of views.



Using the free command or top command I can get the memory information. But specifically, how do I get the total memory used? So that I can return this to the Python function to compare with the memory threshold.









share|improve this question













share|improve this question




share|improve this question








edited Aug 8 at 22:02









Peter Mortensen

1,03821016




1,03821016










asked Aug 8 at 6:51









ron123456

637




637







  • 2




    See also stackoverflow.com/questions/276052/… for other ways to do it in python. In particular, if you need portability across various OSs, the psutil python module seems like the right way to go.
    – Brian Minton
    Aug 8 at 14:11












  • 2




    See also stackoverflow.com/questions/276052/… for other ways to do it in python. In particular, if you need portability across various OSs, the psutil python module seems like the right way to go.
    – Brian Minton
    Aug 8 at 14:11







2




2




See also stackoverflow.com/questions/276052/… for other ways to do it in python. In particular, if you need portability across various OSs, the psutil python module seems like the right way to go.
– Brian Minton
Aug 8 at 14:11




See also stackoverflow.com/questions/276052/… for other ways to do it in python. In particular, if you need portability across various OSs, the psutil python module seems like the right way to go.
– Brian Minton
Aug 8 at 14:11










2 Answers
2






active

oldest

votes

















up vote
10
down vote



accepted










Percentage used memory (excluding buffers and cache):



free | awk 'FNR == 3 print $3/($3+$4)*100'


For your question you added: "above 7.2 gigabyte", but I would assume a percentage might be more flexible.




To expand on this, the same can be used for "percentage free memory":



free | awk 'FNR == 3 print $4/($3+$4)*100'


awk is a pattern scanning tool with loads and loads of parameters. FNR is the input record number in the current input file. Basically the line that is currently processed. So FNR will scan for the 3rd line where the numbers are what you want. The $3 and $4 point to the 3rd and 4th column. If you want the number itself, use:



free | awk 'FNR == 3 print $3'
free | awk 'FNR == 3 print $4'


Example:



$ free
total used free shared buffers cached
Mem: 16419996 16144316 275680 0 447220 12589412
-/+ buffers/cache: 3107684 13312312
Swap: 16761852 38532 16723320
~$ free | awk 'FNR == 3 print $3'
3109056
~$ free | awk 'FNR == 3 print $4'
13311240


If you want with buffers and cache: FNR=2. If you want swap, FNR=4.






share|improve this answer





























    up vote
    15
    down vote













    You can also read the source of free's information, /proc/meminfo:



    ~ head /proc/meminfo
    MemTotal: 4039168 kB
    MemFree: 2567392 kB
    MemAvailable: 3169436 kB
    Buffers: 81756 kB
    Cached: 712808 kB
    SwapCached: 0 kB
    Active: 835276 kB
    Inactive: 457436 kB
    Active(anon): 499080 kB
    Inactive(anon): 17968 kB


    In Python, for example:



    with open('/proc/meminfo') as file:
    for line in file:
    if 'MemFree' in line:
    free_mem_in_kb = line.split()[1]
    break


    will get you the free memory in KB in the free_mem_in_kb variable. With something similar for total memory, you can subtract the values (or add up buffers, cached, etc.).



    You could also create a dictionary of the values in the file:



    from collections import namedtuple
    MemInfoEntry = namedtuple('MemInfoEntry', ['value', 'unit'])

    meminfo =
    with open('/proc/meminfo') as file:
    for line in file:
    key, value, *unit = line.strip().split()
    meminfo[key.rstrip(':')] = MemInfoEntry(value, unit)


    Then retrieve the values with meminfo['MemAvailable'].value, for example.






    share|improve this answer


















    • 4




      +1 - using /proc/meminfo is much more elegant that trying to parse the output of "free". Admittedly the format of free's output is unlikely to change now, but I recently had a script break horribly and make a service nonfunctional because it depended on awking the human-readable output of a different command, of which the format changed slightly due to the utility being updated.
      – Carcer
      Aug 8 at 7:52






    • 3




      @Carcer "Admittedly the format of free's output is unlikely to change now ..." - Actually, exactly that happened about 4 years ago. Don't rely on parsing the output from such tools, if you can help it.
      – marcelm
      Aug 8 at 12:42






    • 4




      @carcer Why is the output of /proc/meminfo less likely to change in the long term than that of free? The choice seems to be between parsing one or the other.
      – Federico Poloni
      Aug 8 at 13:55







    • 4




      @FedericoPoloni because Linus hates changes that break userspace, and /proc/meminfo has been exposed to users for a very long time.
      – muru
      Aug 8 at 14:05






    • 5




      @FedericoPoloni Note that /proc/meminfo is not meant for humans (who can cope with changes in output formatting), but for other programs (which might break on changes). Like muru notes, Linux kernel devs strive to not break userspace using documented APIs (of which /proc/meminfo is one). Additionally, the format for /proc/meminfo is more or less key-value pairs, so adding new fields can be done without breaking backwards compatibility. Breaking changes could still happen, but I do think they're less likely than for free.
      – marcelm
      Aug 8 at 14:30










    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "89"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1063412%2fcheck-available-memory-in-linux%23new-answer', 'question_page');

    );

    Post as a guest






























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    10
    down vote



    accepted










    Percentage used memory (excluding buffers and cache):



    free | awk 'FNR == 3 print $3/($3+$4)*100'


    For your question you added: "above 7.2 gigabyte", but I would assume a percentage might be more flexible.




    To expand on this, the same can be used for "percentage free memory":



    free | awk 'FNR == 3 print $4/($3+$4)*100'


    awk is a pattern scanning tool with loads and loads of parameters. FNR is the input record number in the current input file. Basically the line that is currently processed. So FNR will scan for the 3rd line where the numbers are what you want. The $3 and $4 point to the 3rd and 4th column. If you want the number itself, use:



    free | awk 'FNR == 3 print $3'
    free | awk 'FNR == 3 print $4'


    Example:



    $ free
    total used free shared buffers cached
    Mem: 16419996 16144316 275680 0 447220 12589412
    -/+ buffers/cache: 3107684 13312312
    Swap: 16761852 38532 16723320
    ~$ free | awk 'FNR == 3 print $3'
    3109056
    ~$ free | awk 'FNR == 3 print $4'
    13311240


    If you want with buffers and cache: FNR=2. If you want swap, FNR=4.






    share|improve this answer


























      up vote
      10
      down vote



      accepted










      Percentage used memory (excluding buffers and cache):



      free | awk 'FNR == 3 print $3/($3+$4)*100'


      For your question you added: "above 7.2 gigabyte", but I would assume a percentage might be more flexible.




      To expand on this, the same can be used for "percentage free memory":



      free | awk 'FNR == 3 print $4/($3+$4)*100'


      awk is a pattern scanning tool with loads and loads of parameters. FNR is the input record number in the current input file. Basically the line that is currently processed. So FNR will scan for the 3rd line where the numbers are what you want. The $3 and $4 point to the 3rd and 4th column. If you want the number itself, use:



      free | awk 'FNR == 3 print $3'
      free | awk 'FNR == 3 print $4'


      Example:



      $ free
      total used free shared buffers cached
      Mem: 16419996 16144316 275680 0 447220 12589412
      -/+ buffers/cache: 3107684 13312312
      Swap: 16761852 38532 16723320
      ~$ free | awk 'FNR == 3 print $3'
      3109056
      ~$ free | awk 'FNR == 3 print $4'
      13311240


      If you want with buffers and cache: FNR=2. If you want swap, FNR=4.






      share|improve this answer
























        up vote
        10
        down vote



        accepted







        up vote
        10
        down vote



        accepted






        Percentage used memory (excluding buffers and cache):



        free | awk 'FNR == 3 print $3/($3+$4)*100'


        For your question you added: "above 7.2 gigabyte", but I would assume a percentage might be more flexible.




        To expand on this, the same can be used for "percentage free memory":



        free | awk 'FNR == 3 print $4/($3+$4)*100'


        awk is a pattern scanning tool with loads and loads of parameters. FNR is the input record number in the current input file. Basically the line that is currently processed. So FNR will scan for the 3rd line where the numbers are what you want. The $3 and $4 point to the 3rd and 4th column. If you want the number itself, use:



        free | awk 'FNR == 3 print $3'
        free | awk 'FNR == 3 print $4'


        Example:



        $ free
        total used free shared buffers cached
        Mem: 16419996 16144316 275680 0 447220 12589412
        -/+ buffers/cache: 3107684 13312312
        Swap: 16761852 38532 16723320
        ~$ free | awk 'FNR == 3 print $3'
        3109056
        ~$ free | awk 'FNR == 3 print $4'
        13311240


        If you want with buffers and cache: FNR=2. If you want swap, FNR=4.






        share|improve this answer














        Percentage used memory (excluding buffers and cache):



        free | awk 'FNR == 3 print $3/($3+$4)*100'


        For your question you added: "above 7.2 gigabyte", but I would assume a percentage might be more flexible.




        To expand on this, the same can be used for "percentage free memory":



        free | awk 'FNR == 3 print $4/($3+$4)*100'


        awk is a pattern scanning tool with loads and loads of parameters. FNR is the input record number in the current input file. Basically the line that is currently processed. So FNR will scan for the 3rd line where the numbers are what you want. The $3 and $4 point to the 3rd and 4th column. If you want the number itself, use:



        free | awk 'FNR == 3 print $3'
        free | awk 'FNR == 3 print $4'


        Example:



        $ free
        total used free shared buffers cached
        Mem: 16419996 16144316 275680 0 447220 12589412
        -/+ buffers/cache: 3107684 13312312
        Swap: 16761852 38532 16723320
        ~$ free | awk 'FNR == 3 print $3'
        3109056
        ~$ free | awk 'FNR == 3 print $4'
        13311240


        If you want with buffers and cache: FNR=2. If you want swap, FNR=4.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Aug 8 at 22:03









        Peter Mortensen

        1,03821016




        1,03821016










        answered Aug 8 at 7:00









        Rinzwind

        196k25375509




        196k25375509






















            up vote
            15
            down vote













            You can also read the source of free's information, /proc/meminfo:



            ~ head /proc/meminfo
            MemTotal: 4039168 kB
            MemFree: 2567392 kB
            MemAvailable: 3169436 kB
            Buffers: 81756 kB
            Cached: 712808 kB
            SwapCached: 0 kB
            Active: 835276 kB
            Inactive: 457436 kB
            Active(anon): 499080 kB
            Inactive(anon): 17968 kB


            In Python, for example:



            with open('/proc/meminfo') as file:
            for line in file:
            if 'MemFree' in line:
            free_mem_in_kb = line.split()[1]
            break


            will get you the free memory in KB in the free_mem_in_kb variable. With something similar for total memory, you can subtract the values (or add up buffers, cached, etc.).



            You could also create a dictionary of the values in the file:



            from collections import namedtuple
            MemInfoEntry = namedtuple('MemInfoEntry', ['value', 'unit'])

            meminfo =
            with open('/proc/meminfo') as file:
            for line in file:
            key, value, *unit = line.strip().split()
            meminfo[key.rstrip(':')] = MemInfoEntry(value, unit)


            Then retrieve the values with meminfo['MemAvailable'].value, for example.






            share|improve this answer


















            • 4




              +1 - using /proc/meminfo is much more elegant that trying to parse the output of "free". Admittedly the format of free's output is unlikely to change now, but I recently had a script break horribly and make a service nonfunctional because it depended on awking the human-readable output of a different command, of which the format changed slightly due to the utility being updated.
              – Carcer
              Aug 8 at 7:52






            • 3




              @Carcer "Admittedly the format of free's output is unlikely to change now ..." - Actually, exactly that happened about 4 years ago. Don't rely on parsing the output from such tools, if you can help it.
              – marcelm
              Aug 8 at 12:42






            • 4




              @carcer Why is the output of /proc/meminfo less likely to change in the long term than that of free? The choice seems to be between parsing one or the other.
              – Federico Poloni
              Aug 8 at 13:55







            • 4




              @FedericoPoloni because Linus hates changes that break userspace, and /proc/meminfo has been exposed to users for a very long time.
              – muru
              Aug 8 at 14:05






            • 5




              @FedericoPoloni Note that /proc/meminfo is not meant for humans (who can cope with changes in output formatting), but for other programs (which might break on changes). Like muru notes, Linux kernel devs strive to not break userspace using documented APIs (of which /proc/meminfo is one). Additionally, the format for /proc/meminfo is more or less key-value pairs, so adding new fields can be done without breaking backwards compatibility. Breaking changes could still happen, but I do think they're less likely than for free.
              – marcelm
              Aug 8 at 14:30














            up vote
            15
            down vote













            You can also read the source of free's information, /proc/meminfo:



            ~ head /proc/meminfo
            MemTotal: 4039168 kB
            MemFree: 2567392 kB
            MemAvailable: 3169436 kB
            Buffers: 81756 kB
            Cached: 712808 kB
            SwapCached: 0 kB
            Active: 835276 kB
            Inactive: 457436 kB
            Active(anon): 499080 kB
            Inactive(anon): 17968 kB


            In Python, for example:



            with open('/proc/meminfo') as file:
            for line in file:
            if 'MemFree' in line:
            free_mem_in_kb = line.split()[1]
            break


            will get you the free memory in KB in the free_mem_in_kb variable. With something similar for total memory, you can subtract the values (or add up buffers, cached, etc.).



            You could also create a dictionary of the values in the file:



            from collections import namedtuple
            MemInfoEntry = namedtuple('MemInfoEntry', ['value', 'unit'])

            meminfo =
            with open('/proc/meminfo') as file:
            for line in file:
            key, value, *unit = line.strip().split()
            meminfo[key.rstrip(':')] = MemInfoEntry(value, unit)


            Then retrieve the values with meminfo['MemAvailable'].value, for example.






            share|improve this answer


















            • 4




              +1 - using /proc/meminfo is much more elegant that trying to parse the output of "free". Admittedly the format of free's output is unlikely to change now, but I recently had a script break horribly and make a service nonfunctional because it depended on awking the human-readable output of a different command, of which the format changed slightly due to the utility being updated.
              – Carcer
              Aug 8 at 7:52






            • 3




              @Carcer "Admittedly the format of free's output is unlikely to change now ..." - Actually, exactly that happened about 4 years ago. Don't rely on parsing the output from such tools, if you can help it.
              – marcelm
              Aug 8 at 12:42






            • 4




              @carcer Why is the output of /proc/meminfo less likely to change in the long term than that of free? The choice seems to be between parsing one or the other.
              – Federico Poloni
              Aug 8 at 13:55







            • 4




              @FedericoPoloni because Linus hates changes that break userspace, and /proc/meminfo has been exposed to users for a very long time.
              – muru
              Aug 8 at 14:05






            • 5




              @FedericoPoloni Note that /proc/meminfo is not meant for humans (who can cope with changes in output formatting), but for other programs (which might break on changes). Like muru notes, Linux kernel devs strive to not break userspace using documented APIs (of which /proc/meminfo is one). Additionally, the format for /proc/meminfo is more or less key-value pairs, so adding new fields can be done without breaking backwards compatibility. Breaking changes could still happen, but I do think they're less likely than for free.
              – marcelm
              Aug 8 at 14:30












            up vote
            15
            down vote










            up vote
            15
            down vote









            You can also read the source of free's information, /proc/meminfo:



            ~ head /proc/meminfo
            MemTotal: 4039168 kB
            MemFree: 2567392 kB
            MemAvailable: 3169436 kB
            Buffers: 81756 kB
            Cached: 712808 kB
            SwapCached: 0 kB
            Active: 835276 kB
            Inactive: 457436 kB
            Active(anon): 499080 kB
            Inactive(anon): 17968 kB


            In Python, for example:



            with open('/proc/meminfo') as file:
            for line in file:
            if 'MemFree' in line:
            free_mem_in_kb = line.split()[1]
            break


            will get you the free memory in KB in the free_mem_in_kb variable. With something similar for total memory, you can subtract the values (or add up buffers, cached, etc.).



            You could also create a dictionary of the values in the file:



            from collections import namedtuple
            MemInfoEntry = namedtuple('MemInfoEntry', ['value', 'unit'])

            meminfo =
            with open('/proc/meminfo') as file:
            for line in file:
            key, value, *unit = line.strip().split()
            meminfo[key.rstrip(':')] = MemInfoEntry(value, unit)


            Then retrieve the values with meminfo['MemAvailable'].value, for example.






            share|improve this answer














            You can also read the source of free's information, /proc/meminfo:



            ~ head /proc/meminfo
            MemTotal: 4039168 kB
            MemFree: 2567392 kB
            MemAvailable: 3169436 kB
            Buffers: 81756 kB
            Cached: 712808 kB
            SwapCached: 0 kB
            Active: 835276 kB
            Inactive: 457436 kB
            Active(anon): 499080 kB
            Inactive(anon): 17968 kB


            In Python, for example:



            with open('/proc/meminfo') as file:
            for line in file:
            if 'MemFree' in line:
            free_mem_in_kb = line.split()[1]
            break


            will get you the free memory in KB in the free_mem_in_kb variable. With something similar for total memory, you can subtract the values (or add up buffers, cached, etc.).



            You could also create a dictionary of the values in the file:



            from collections import namedtuple
            MemInfoEntry = namedtuple('MemInfoEntry', ['value', 'unit'])

            meminfo =
            with open('/proc/meminfo') as file:
            for line in file:
            key, value, *unit = line.strip().split()
            meminfo[key.rstrip(':')] = MemInfoEntry(value, unit)


            Then retrieve the values with meminfo['MemAvailable'].value, for example.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Aug 9 at 2:57

























            answered Aug 8 at 7:37









            muru

            1




            1







            • 4




              +1 - using /proc/meminfo is much more elegant that trying to parse the output of "free". Admittedly the format of free's output is unlikely to change now, but I recently had a script break horribly and make a service nonfunctional because it depended on awking the human-readable output of a different command, of which the format changed slightly due to the utility being updated.
              – Carcer
              Aug 8 at 7:52






            • 3




              @Carcer "Admittedly the format of free's output is unlikely to change now ..." - Actually, exactly that happened about 4 years ago. Don't rely on parsing the output from such tools, if you can help it.
              – marcelm
              Aug 8 at 12:42






            • 4




              @carcer Why is the output of /proc/meminfo less likely to change in the long term than that of free? The choice seems to be between parsing one or the other.
              – Federico Poloni
              Aug 8 at 13:55







            • 4




              @FedericoPoloni because Linus hates changes that break userspace, and /proc/meminfo has been exposed to users for a very long time.
              – muru
              Aug 8 at 14:05






            • 5




              @FedericoPoloni Note that /proc/meminfo is not meant for humans (who can cope with changes in output formatting), but for other programs (which might break on changes). Like muru notes, Linux kernel devs strive to not break userspace using documented APIs (of which /proc/meminfo is one). Additionally, the format for /proc/meminfo is more or less key-value pairs, so adding new fields can be done without breaking backwards compatibility. Breaking changes could still happen, but I do think they're less likely than for free.
              – marcelm
              Aug 8 at 14:30












            • 4




              +1 - using /proc/meminfo is much more elegant that trying to parse the output of "free". Admittedly the format of free's output is unlikely to change now, but I recently had a script break horribly and make a service nonfunctional because it depended on awking the human-readable output of a different command, of which the format changed slightly due to the utility being updated.
              – Carcer
              Aug 8 at 7:52






            • 3




              @Carcer "Admittedly the format of free's output is unlikely to change now ..." - Actually, exactly that happened about 4 years ago. Don't rely on parsing the output from such tools, if you can help it.
              – marcelm
              Aug 8 at 12:42






            • 4




              @carcer Why is the output of /proc/meminfo less likely to change in the long term than that of free? The choice seems to be between parsing one or the other.
              – Federico Poloni
              Aug 8 at 13:55







            • 4




              @FedericoPoloni because Linus hates changes that break userspace, and /proc/meminfo has been exposed to users for a very long time.
              – muru
              Aug 8 at 14:05






            • 5




              @FedericoPoloni Note that /proc/meminfo is not meant for humans (who can cope with changes in output formatting), but for other programs (which might break on changes). Like muru notes, Linux kernel devs strive to not break userspace using documented APIs (of which /proc/meminfo is one). Additionally, the format for /proc/meminfo is more or less key-value pairs, so adding new fields can be done without breaking backwards compatibility. Breaking changes could still happen, but I do think they're less likely than for free.
              – marcelm
              Aug 8 at 14:30







            4




            4




            +1 - using /proc/meminfo is much more elegant that trying to parse the output of "free". Admittedly the format of free's output is unlikely to change now, but I recently had a script break horribly and make a service nonfunctional because it depended on awking the human-readable output of a different command, of which the format changed slightly due to the utility being updated.
            – Carcer
            Aug 8 at 7:52




            +1 - using /proc/meminfo is much more elegant that trying to parse the output of "free". Admittedly the format of free's output is unlikely to change now, but I recently had a script break horribly and make a service nonfunctional because it depended on awking the human-readable output of a different command, of which the format changed slightly due to the utility being updated.
            – Carcer
            Aug 8 at 7:52




            3




            3




            @Carcer "Admittedly the format of free's output is unlikely to change now ..." - Actually, exactly that happened about 4 years ago. Don't rely on parsing the output from such tools, if you can help it.
            – marcelm
            Aug 8 at 12:42




            @Carcer "Admittedly the format of free's output is unlikely to change now ..." - Actually, exactly that happened about 4 years ago. Don't rely on parsing the output from such tools, if you can help it.
            – marcelm
            Aug 8 at 12:42




            4




            4




            @carcer Why is the output of /proc/meminfo less likely to change in the long term than that of free? The choice seems to be between parsing one or the other.
            – Federico Poloni
            Aug 8 at 13:55





            @carcer Why is the output of /proc/meminfo less likely to change in the long term than that of free? The choice seems to be between parsing one or the other.
            – Federico Poloni
            Aug 8 at 13:55





            4




            4




            @FedericoPoloni because Linus hates changes that break userspace, and /proc/meminfo has been exposed to users for a very long time.
            – muru
            Aug 8 at 14:05




            @FedericoPoloni because Linus hates changes that break userspace, and /proc/meminfo has been exposed to users for a very long time.
            – muru
            Aug 8 at 14:05




            5




            5




            @FedericoPoloni Note that /proc/meminfo is not meant for humans (who can cope with changes in output formatting), but for other programs (which might break on changes). Like muru notes, Linux kernel devs strive to not break userspace using documented APIs (of which /proc/meminfo is one). Additionally, the format for /proc/meminfo is more or less key-value pairs, so adding new fields can be done without breaking backwards compatibility. Breaking changes could still happen, but I do think they're less likely than for free.
            – marcelm
            Aug 8 at 14:30




            @FedericoPoloni Note that /proc/meminfo is not meant for humans (who can cope with changes in output formatting), but for other programs (which might break on changes). Like muru notes, Linux kernel devs strive to not break userspace using documented APIs (of which /proc/meminfo is one). Additionally, the format for /proc/meminfo is more or less key-value pairs, so adding new fields can be done without breaking backwards compatibility. Breaking changes could still happen, but I do think they're less likely than for free.
            – marcelm
            Aug 8 at 14:30

















             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1063412%2fcheck-available-memory-in-linux%23new-answer', 'question_page');

            );

            Post as a guest













































































            Comments

            Popular posts from this blog

            What does second last employer means? [closed]

            List of Gilmore Girls characters

            One-line joke