3 Commits

Author SHA1 Message Date
Philip Withnall
30aff12d89 gmemorymonitorpoll: Hold a weak ref from a source callback to the monitor
It’s possible for the dispatch of the timeout source to race with the
finalisation of the `GMemoryMonitorPoll`, given that the timeout is run
in the GLib worker thread.

Protect against that by holding a thread-safe weak ref on the
`GMemoryMonitor` in the callback data.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Fixes: #3758
2025-08-12 13:24:52 +01:00
Kate Hsuan
e9b0fe2879 gio: gmemorymonitorpoll: Fix unit test error since the callback returns earlier
The value overriding has to be set before testing the value and returning
the callback. Otherwise, the callback can't emit a signal to the test
program.
2025-07-23 20:09:26 +08:00
Kate Hsuan
32ea357130 gio: gmemorymonitorpoll: Poll backend for the GMemoryMonitor
This backend periodically watch the memory free ratio through sysinfo().
It signals the applications when the memory free ratio drops to 40%, 30%,
and 20% for LOW, MEDIUM, CRITICAL status, respectively.
2025-07-21 17:39:25 +01:00