forked from redis/redis
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
start_server {tags {"lazyfree"}} { | ||
test "UNLINK can reclaim memory in background" { | ||
set orig_mem [s used_memory] | ||
set args {} | ||
for {set i 0} {$i < 100000} {incr i} { | ||
lappend args $i | ||
} | ||
r sadd myset {*}$args | ||
assert {[r scard myset] == 100000} | ||
set peak_mem [s used_memory] | ||
assert {[r unlink myset] == 1} | ||
assert {$peak_mem > $orig_mem+1000000} | ||
wait_for_condition 50 100 { | ||
[s used_memory] < $peak_mem && | ||
[s used_memory] < $orig_mem*2 | ||
} else { | ||
fail "Memory is not reclaimed by UNLINK" | ||
} | ||
} | ||
|
||
test "FLUSHDB ASYNC can reclaim memory in background" { | ||
set orig_mem [s used_memory] | ||
set args {} | ||
for {set i 0} {$i < 100000} {incr i} { | ||
lappend args $i | ||
} | ||
r sadd myset {*}$args | ||
assert {[r scard myset] == 100000} | ||
set peak_mem [s used_memory] | ||
r flushdb async | ||
assert {$peak_mem > $orig_mem+1000000} | ||
wait_for_condition 50 100 { | ||
[s used_memory] < $peak_mem && | ||
[s used_memory] < $orig_mem*2 | ||
} else { | ||
fail "Memory is not reclaimed by FLUSHDB ASYNC" | ||
} | ||
} | ||
} |