[gjs] object: Run JS_updateMallocCounter() when creating GObjects
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs] object: Run JS_updateMallocCounter() when creating GObjects
- Date: Sat, 17 Sep 2011 14:04:50 +0000 (UTC)
commit 72bc4307860a315f9d2173d700582add938d79a0
Author: Colin Walters <walters verbum org>
Date: Thu Sep 15 23:07:11 2011 -0400
object: Run JS_updateMallocCounter() when creating GObjects
We need to ensure the garbage collector runs *sometime*. It's easily
possible to make tiny proxies for large native objects with gjs. Now,
Mozilla calls JS_updateMallocCounter() in a few places, namely the
Canvas stuff and when creating XPC proxies (roughly their GObject
equivalent).
This patch aims to match the latter one.
https://bugzilla.gnome.org/show_bug.cgi?id=659253
gi/object.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
---
diff --git a/gi/object.c b/gi/object.c
index 7e090d9..6fefc61 100644
--- a/gi/object.c
+++ b/gi/object.c
@@ -674,6 +674,7 @@ GJS_NATIVE_CONSTRUCTOR_DECLARE(object_instance)
if (unthreadsafe_template_for_constructor.gobj == NULL) {
GParameter *params;
int n_params;
+ GTypeQuery query;
gtype = g_registered_type_info_get_g_type( (GIRegisteredTypeInfo*) priv->info);
if (gtype == G_TYPE_NONE) {
@@ -692,6 +693,9 @@ GJS_NATIVE_CONSTRUCTOR_DECLARE(object_instance)
priv->gobj = g_object_newv(gtype, n_params, params);
free_g_params(params, n_params);
+ g_type_query(gtype, &query);
+ JS_updateMallocCounter(context, query.instance_size);
+
if (G_IS_INITIALLY_UNOWNED(priv->gobj) &&
!g_object_is_floating(priv->gobj)) {
/* GtkWindow does not return a ref to caller of g_object_new.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]