We don't want to count AOF buffers and slaves output buffers as * used memory: the eviction should use mostly data size. This function * returns the sum of AOF and slaves buffer. */
| 341 | * used memory: the eviction should use mostly data size. This function |
| 342 | * returns the sum of AOF and slaves buffer. */ |
| 343 | size_t freeMemoryGetNotCountedMemory(void) { |
| 344 | serverAssert(GlobalLocksAcquired()); |
| 345 | size_t overhead = 0; |
| 346 | int slaves = listLength(g_pserver->slaves); |
| 347 | |
| 348 | if (slaves) { |
| 349 | listIter li; |
| 350 | listNode *ln; |
| 351 | |
| 352 | listRewind(g_pserver->slaves,&li); |
| 353 | while((ln = listNext(&li))) { |
| 354 | client *replica = (client*)listNodeValue(ln); |
| 355 | std::unique_lock<fastlock>(replica->lock); |
| 356 | /* we don't wish to multiple count the replication backlog shared usage */ |
| 357 | overhead += (getClientOutputBufferMemoryUsage(replica) - getClientReplicationBacklogSharedUsage(replica)); |
| 358 | } |
| 359 | } |
| 360 | |
| 361 | /* also don't count the replication backlog memory |
| 362 | * that's where the replication clients get their memory from */ |
| 363 | overhead += g_pserver->repl_backlog_size - g_pserver->repl_backlog_config_size; |
| 364 | |
| 365 | if (g_pserver->aof_state != AOF_OFF) { |
| 366 | overhead += sdsalloc(g_pserver->aof_buf)+aofRewriteBufferSize(); |
| 367 | } |
| 368 | return overhead; |
| 369 | } |
| 370 | |
| 371 | /* Get the memory status from the point of view of the maxmemory directive: |
| 372 | * if the memory used is under the maxmemory setting then C_OK is returned. |
no test coverage detected