[glib/wip/hadess/fix-gmemory-monitor-example: 14/14] docs: Add full code example for GMemoryMonitor
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/hadess/fix-gmemory-monitor-example: 14/14] docs: Add full code example for GMemoryMonitor
- Date: Tue, 7 Jan 2020 15:32:48 +0000 (UTC)
commit cb06cd4c1d85e2218590dbd6bebc89b964f4f9be
Author: Bastien Nocera <hadess hadess net>
Date: Wed Dec 18 12:52:27 2019 +0100
docs: Add full code example for GMemoryMonitor
gio/gmemorymonitor.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
---
diff --git a/gio/gmemorymonitor.c b/gio/gmemorymonitor.c
index d0c9cfb0d..00f56eb5f 100644
--- a/gio/gmemorymonitor.c
+++ b/gio/gmemorymonitor.c
@@ -50,6 +50,25 @@
*
* See #GMemoryMonitorWarningLevel for details on the various warning levels.
*
+ * |[<!-- language="C" -->
+ * static void
+ * warning_cb (GMemoryMonitor *m, GMemoryMonitorWarningLevel level)
+ * {
+ * g_debug ("Warning level: %d", level);
+ * if (warning_level > G_MEMORY_MONITOR_WARNING_LEVEL_LOW)
+ * drop_caches ();
+ * }
+ *
+ * static void
+ * monitor_low_memory (void)
+ * {
+ * GMemoryMonitor *m;
+ * m = g_memory_monitor_dup_default ();
+ * g_signal_connect (G_OBJECT (m), "low-memory-warning",
+ * G_CALLBACK (warning_cb), NULL);
+ * }
+ * ]|
+ *
* Since: 2.64
*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]