in reply to Inactive memory and OSX

Thank you both!

Dave, you're absolutely right, cat | grep does the same thing...

...and thanks for the link Browser, it makes more sense now. I had been purging after each run. It's a little irritating, because others will likely need to use these programs in future, and some of them may use OSX.

It would be ideal if it were possible to "switch off" this behaviour from start of the script.

For now, purging at the end will have to do:

 system("purge") if $^O eq "darwin";

Thanks guys!

Replies are listed 'Best First'.
Re^2: Inactive memory and OSX
by BrowserUk (Patriarch) on Jul 05, 2013 at 08:24 UTC
    It would be ideal if it were possible to "switch off" this behaviour from start of the script. For now, purging at the end will have to do:

    The way I understand it, inactive memory gets returned to the system memory pool on demand. That is, as soon as something else (another process) needs it, it gets made available immediately and cheaply without any need to manually purge it.

    It is only held as 'inactive' while nothing else asks for it, on the off chance (and frequently true), that you might re-run the same program and thus it makes the second (and any subsequent runs) of the program quicker.

    In that respect, you can simple consider inactive memory a part of the free memory pool and your 'need to purge' is purely psychological.

    I'd also have questions regarding whether running purge from inside the process that you're trying to purge will work. system starts another process, but your program won't finish until the system call returns. (I can't try it; its my brother that runs OSX and its the middle of the night where he is.)


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      your 'need to purge' is purely psychological

      You're probably right! It does seem to me that browsers and text editors etc are slower to load and run while this is going on, but maybe that's simply because the perl script claims the 'inactive' memory that these other programs had been using.

      The system("purge") call does work, but as you point out, it's probably just as well to leave it out.

      Thanks again!

      Michael
        but maybe that's simply because the perl script claims the 'inactive' memory that these other programs had been using.

        Indeed. It is that exact scenario that my brother experienced that brought this to my attention.

        He'd just installed a new piece of software that used a substantial amount of memory, and he noticed that all his other regular programs seemed less responsive. He thought he'd acquired a virus :)

        Once we worked out that it was just that those other programs were no longer benefiting from having much of their runtime state preserved in 'inactive memory' whilst the new program was running, he praised rather than cursed the feature and was happy.


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.