Now maxmemory, VM, and everything else uses the fast RSS memory used estimation instead of raw memory reported by zmalloc(). This means that setting maxmemory to 2GB will really have the effect of using up to 2GB of memory.

This commit is contained in:
antirez
2010-11-02 11:50:55 +01:00
parent 7d47ecd543
commit a3e60027e7
3 changed files with 16 additions and 18 deletions

View File

@ -280,11 +280,11 @@ int loadAppendOnlyFile(char *filename) {
/* Handle swapping while loading big datasets when VM is on */
force_swapout = 0;
if ((zmalloc_used_memory() - server.vm_max_memory) > 1024*1024*32)
if ((redisEstimateRSS() - server.vm_max_memory) > 1024*1024*32)
force_swapout = 1;
if (server.vm_enabled && force_swapout) {
while (zmalloc_used_memory() > server.vm_max_memory) {
while (redisEstimateRSS() > server.vm_max_memory) {
if (vmSwapOneObjectBlocking() == REDIS_ERR) break;
}
}