1
0

test_lazyfree.tcl 962 B

1234567891011121314151617181920212223242526272829303132
  1. set testmodule [file normalize tests/modules/test_lazyfree.so]
  2. start_server {tags {"modules"}} {
  3. r module load $testmodule
  4. test "modules allocated memory can be reclaimed in the background" {
  5. set orig_mem [s used_memory]
  6. set rd [redis_deferring_client]
  7. # LAZYFREE_THRESHOLD is 64
  8. for {set i 0} {$i < 10000} {incr i} {
  9. $rd lazyfreelink.insert lazykey $i
  10. }
  11. for {set j 0} {$j < 10000} {incr j} {
  12. $rd read
  13. }
  14. assert {[r lazyfreelink.len lazykey] == 10000}
  15. set peak_mem [s used_memory]
  16. assert {[r unlink lazykey] == 1}
  17. assert {$peak_mem > $orig_mem+10000}
  18. wait_for_condition 50 100 {
  19. [s used_memory] < $peak_mem &&
  20. [s used_memory] < $orig_mem*2 &&
  21. [string match {*lazyfreed_objects:1*} [r info Memory]]
  22. } else {
  23. fail "Module memory is not reclaimed by UNLINK"
  24. }
  25. }
  26. }