I am pretty sure that _SC_AVPHYS_PAGES won't include memory used for buffers and disk cache (and an experiment on my machine seems to confirm that), so it is pretty worthless I would say. Sad. Besides, I think that the amount of memory available without swapping any other process would be too low a threshold.