1. A method comprising: providing a near and far memory coupled to a processor, wherein said near memory is faster than said far memory and said near memory is backed by said far memory; compressing data to be stored in said near memory using a codec; compacting said compressed data only in response to an indication that free memory is needed; storing said compacted data so that said compressed and compacted data's footprint is less than that of compressed data before compaction; and providing a buffer between said codec and said near memory, said buffer to store compressed data for said codec, such that said compressed data in said buffer has a smaller footprint than the compressed data from the codec.