Hacker News new | ask | show | jobs
by collint 5163 days ago
You can run `purge` in a terminal to free your 'inactive' ram.

I've set up a cron job to purge frequently, keeps thing humming.

3 comments

That's a terrible idea. `purge` is not a tool for freeing inactive ram. It's a tool for deleting the filesystem cache in order to simulate cold boot conditions for performance analysis. Yes, it has the side effect of reducing memory usage, inasmuch as it's throwing away stuff that was kept in memory. But that doesn't make it an appropriate tool to use.
What's the downside? It worked for him.
The downside is it slows filesystem access down across the board until the caches get repopulated. So sure, go ahead and use it if you like having a slow filesystem.

Caches exist for a reason. Deleting them willy-nilly tends to be a bad idea.

Yeah, I've had zero problems doing this for over a year. I used to get into swap hell every other day and now my life is beautiful and awesome.
From my days of optimizing Firefox startup on the Mac, I remember that this doesn't work 100%. The only way to ensure that caches are 100% purged is to unmount the filesystem.
Can you explain a bit more how this works?

The `purge` command has a pretty short man page:

> purge -- force disk cache to be purged (flushed and emptied)

> Purge can be used to approximate initial boot conditions with a cold disk buffer cache for performance analysis. It does not affect anonymous memory that has been allocated through malloc, vm_allocate, etc.

[This seems to talk about it more: http://workstuff.tumblr.com/post/19036310553/two-things-that...

On my 10.5 laptop it didn't seem to dramatically decrease the memory marked "inactive".]

yeah, it's not directly attacking your 'inactive' memory. Just the disk cache, which shows up in the chart as 'inactive'. I'm not familiar with other cases that fit into the 'inactive' piece of the pie.

I have regularly seen 1-3G of ram get free'd up on a 'purge'

Cmd line syntax, for the lazy, please?
I made a bash script for it and I'll share it, hacker 2 hacker. Goes a little something like this:

#!/bin/bash

purge

post it to GitHub so I can fork it to support zsh
What license are you releasing your software under?
Proprietary, nanananana
...sudo purge? ;)

> purge // wait ~10 seconds Done.

purge