Przeglądaj źródła

feat: extract real reclaim to a function

Put real reclaim work in a function so we can print memory usage info
even if we don't really perform the reclaim.

Signed-off-by: greatbridf <greatbridf@icloud.com>
greatbridf 5 dni temu
rodzic
commit
658f70da75
1 zmienionych plików z 11 dodań i 11 usunięć
  1. 11 11
      reclaimer.sh

+ 11 - 11
reclaimer.sh

@@ -146,15 +146,7 @@ wait_for_next_run() {
 	sleep "$interval"
 }
 
-reclaim_run() {
-	update_states
-
-	[ -n "$debug" ] && dump_reclaim_args
-
-	if ! should_reclaim; then
-		return
-	fi
-
+start_reclaim() {
 	reclaim_size_kb="$(calc_size_to_reclaim_kb)"
 
 	if ! reclaim "${reclaim_size_kb}K"; then
@@ -163,10 +155,18 @@ reclaim_run() {
 	fi
 
 	log_info "reclaimed memory ${reclaim_size_kb}K"
+}
 
-	[ -n "$debug" ] && dump_memusage
+reclaim_run() {
+	update_states
+
+	[ -n "$debug" ] && dump_reclaim_args
+
+	if should_reclaim; then
+		start_reclaim
+	fi
 
-	return
+	[ -n "$debug" ] && dump_memusage
 }
 
 while getopts "s:t:i:l:dh" arg; do