[glib: 1/2] gobject: Mention quark memory usage for g_object_set_data()
- From: Sebastian Dröge <sdroege src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 1/2] gobject: Mention quark memory usage for g_object_set_data()
- Date: Thu, 7 Mar 2019 11:50:47 +0000 (UTC)
commit 2a570dc5af9becb4997468e9c51bddb1a6cc3404
Author: Philip Withnall <withnall endlessm com>
Date: Thu Mar 7 10:56:47 2019 +0000
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 <withnall endlessm com>
Fixes: #682
gobject/gobject.c | 8 ++++++++
1 file changed, 8 insertions(+)
---
diff --git a/gobject/gobject.c b/gobject/gobject.c
index 22c2cb39e..3095743c5 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.
*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]