4 ms·
This is not usually true. Memory compression prioritizes speed not compression ratio so even something like a bitmap from a JPEG source is not likely to be very
by xenadu02 5y ago
This is not usually true. Memory compression prioritizes speed not compression ratio so even something like a bitmap from a JPEG source is not likely to be very compressed. Freeing the buffer is still a net win.
Further the pages themselves (for a large allocation) don't all get touched when freed so the kernel can skip decompressing them.
Measure the behavior of your application. Most of the time freeing cached values is the correct response to memory pressure, or use things like NSCache that handle it for you.
- astrange 5y agoIt is true except for freeing large allocations; that's the only safe thing. Calculating what you have to free can also be problematic, or running a GC which has to decompress pages to scan pointers etc. This will come up if you see your app getting background killed. If nothing bad happens then nothing bad happens, of course. You honestly shouldn't use NSCache as nobody understands what it does, or tests its eviction behavior, and what it actually does - evict everything under memory pressure - is probably the time you want your cache to work.