Cache: fix a bug where the disk cache size would overflow the maximum
disk cache size allowed

Cache: Prefer using free_count + inactive_count to reflect the amount
of free RAM on MacOSX. Need to find a way to get the equivalent on the
other OSes.

Image: prefer filling the bitmap and resizing it once the memory has
been allocated for the buffer