Commit e706cc9c authored by Bastien Nocera's avatar Bastien Nocera

Merge branch 'wip/hadess/fix-gmemory-monitor-example' into 'master'

GMemoryMonitor docs fixes

See merge request !1294
parents 4151dfea 2394bc75
Pipeline #141714 passed with stages
in 25 minutes and 19 seconds
......@@ -1980,13 +1980,10 @@ typedef enum {
*
* Note that because new values might be added, it is recommended that applications check
* #GMemoryMonitorWarningLevel as ranges, for example:
* <example>
* <title>Comparing memory warning levels</title>
* <programlisting>
* |[<!-- language="C" -->
* if (warning_level > G_MEMORY_MONITOR_WARNING_LEVEL_LOW)
* drop_caches ();
* </programlisting>
* </example>
* ]|
*
* Since: 2.64
*/
......
......@@ -50,6 +50,29 @@
*
* 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 GMemoryMonitor *
* 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);
* return m;
* }
* ]|
*
* Don't forget to disconnect the #GMemoryMonitor::low-memory-warning
* signal, and unref the #GMemoryMonitor itself when exiting.
*
* Since: 2.64
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment