java-gobject-introspection r62 - trunk/src/org/gnome/gir/gobject



Author: walters
Date: Thu Sep 18 17:16:06 2008
New Revision: 62
URL: http://svn.gnome.org/viewvc/java-gobject-introspection?rev=62&view=rev

Log:
Some comments on memory management


Modified:
   trunk/src/org/gnome/gir/gobject/GObject.java

Modified: trunk/src/org/gnome/gir/gobject/GObject.java
==============================================================================
--- trunk/src/org/gnome/gir/gobject/GObject.java	(original)
+++ trunk/src/org/gnome/gir/gobject/GObject.java	Thu Sep 18 17:16:06 2008
@@ -100,6 +100,9 @@
         if (init.ownsHandle) {
             strongReferences.put(this, Boolean.TRUE);
             
+            /* Floating refs are just a convenience for C; we always want only strong
+             * nonfloating refs for objects which have a JVM peer.
+             */
             boolean wasFloating = GObjectAPI.gobj.g_object_is_floating(this);
             if (wasFloating)
             	GObjectAPI.gobj.g_object_ref_sink(this);
@@ -109,8 +112,14 @@
              */
             GObjectAPI.gobj.g_object_add_toggle_ref(init.ptr, toggle, objectID);
             
+            /* The weak notify is just a convenient hook into object destruction so we
+             * can clear out our signal handlers hash.
+             */
             GObjectAPI.gobj.g_object_weak_ref(this, weakNotify, null);
             
+            /* Since we normally have a strong reference given to us (except in special cases),
+             * here we unref and this should normally just leave the toggle reference.
+             */ 
             if (!init.needRef) {
                 unref();
             }            



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]