Skip to content

Commit

Permalink
change memory limits, readd scheduled meminfo
Browse files Browse the repository at this point in the history
  • Loading branch information
xaki23 committed Dec 28, 2022
1 parent 609f529 commit 9b00613
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions memory_pressure.ml
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,27 @@ let report_mem_usage stats =

let init () =
Gc.full_major ();
let stats = Xen_os.Memory.quick_stat () in
report_mem_usage stats
Lwt.async (fun () ->
let rec aux () =
Gc.full_major ();
Xen_os.Memory.trim ();
let stats = Xen_os.Memory.quick_stat () in
report_mem_usage stats;
Xen_os.Time.sleep_ns (Duration.of_f 60.0) >>= fun () ->
aux ()
in
aux ()
)

let status () =
let stats = Xen_os.Memory.quick_stat () in
if fraction_free stats > 0.5 then `Ok
if fraction_free stats > 0.1 then `Ok
else (
Gc.full_major ();
Xen_os.Memory.trim ();
let stats = Xen_os.Memory.quick_stat () in
if fraction_free stats < 0.6 then begin
report_mem_usage stats;
report_mem_usage stats;
if fraction_free stats < 0.1 then begin
`Memory_critical
end else `Ok
)

0 comments on commit 9b00613

Please sign in to comment.