From 2a570dc5af9becb4997468e9c51bddb1a6cc3404 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 7 Mar 2019 10:56:47 +0000 Subject: [PATCH] gobject: Mention quark memory usage for g_object_set_data() g_object_set_data() should only ever be used with a small, bounded set of keys, or the memory usage of the quark lookup table will grow unbounded. Document that. Signed-off-by: Philip Withnall Fixes: #682 --- gobject/gobject.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gobject/gobject.c b/gobject/gobject.c index 22c2cb39e9..3095743c5f 100644 --- a/gobject/gobject.c +++ b/gobject/gobject.c @@ -3629,6 +3629,11 @@ g_object_get_data (GObject *object, * * If the object already had an association with that name, * the old association will be destroyed. + * + * Internally, the @key is converted to a #GQuark using g_quark_from_string(). + * This means a copy of @key is kept permanently (even after @object has been + * finalized) — so it is recommended to only use a small, bounded set of values + * for @key in your program, to avoid the #GQuark storage growing unbounded. */ void g_object_set_data (GObject *object, @@ -3707,6 +3712,9 @@ g_object_dup_data (GObject *object, * or may not include using @old_destroy as sometimes replacement * should not destroy the object in the normal way. * + * See g_object_set_data() for guidance on using a small, bounded set of values + * for @key. + * * Returns: %TRUE if the existing value for @key was replaced * by @newval, %FALSE otherwise. * -- GitLab