java-gobject-introspection r127 - trunk/src/org/gnome/gir/gobject
- From: walters svn gnome org
- To: svn-commits-list gnome org
- Subject: java-gobject-introspection r127 - trunk/src/org/gnome/gir/gobject
- Date: Mon, 17 Nov 2008 02:05:02 +0000 (UTC)
Author: walters
Date: Mon Nov 17 02:05:02 2008
New Revision: 127
URL: http://svn.gnome.org/viewvc/java-gobject-introspection?rev=127&view=rev
Log:
Tweak memory debug bits
Modified:
trunk/src/org/gnome/gir/gobject/GObject.java
trunk/src/org/gnome/gir/gobject/NativeObject.java
trunk/src/org/gnome/gir/gobject/RefCountedObject.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 Mon Nov 17 02:05:02 2008
@@ -51,6 +51,7 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
+import org.gnome.gir.gobject.GObjectAPI.GObjectStruct;
import org.gnome.gir.gobject.GObjectAPI.GParamSpec;
import org.gnome.gir.gobject.GObjectAPI.GToggleNotify;
import org.gnome.gir.gobject.GObjectAPI.GWeakNotify;
@@ -76,6 +77,21 @@
*/
private Map<Long,Callback> signalHandlers = new HashMap<Long, Callback>();
+ private static final void debugMemory(GObject obj, String fmt, Object... args) {
+ if (NativeObject.Internals.debugMemory) {
+ Object[] newArgs = new Object[args.length+2];
+ System.arraycopy(args, 0, newArgs, 1, args.length);
+ newArgs[0] = obj;
+ if (obj != null) {
+ GObjectStruct objStruct = new GObjectAPI.GObjectStruct(obj);
+ newArgs[newArgs.length-1] = objStruct.ref_count;
+ } else {
+ newArgs[newArgs.length-1] = "<null>";
+ }
+ NativeObject.Internals.debugMemory(fmt, newArgs);
+ }
+ }
+
/**
* A tagging interface to mark classes which are GObject property bags.
* @author walters
@@ -106,10 +122,10 @@
*/
boolean wasFloating = GObjectAPI.gobj.g_object_is_floating(this);
if (wasFloating) {
- NativeObject.Internals.debugMemory(this, "SINK AND TOGGLE %s %s");
+ debugMemory(this, "SINK AND TOGGLE %s %s%n");
GObjectAPI.gobj.g_object_ref_sink(this);
} else {
- NativeObject.Internals.debugMemory(this, "TOGGLE %s %s");
+ debugMemory(this, "INIT TOGGLE %s %s%n");
}
/*
@@ -222,7 +238,7 @@
@Override
protected void finalize() throws Throwable {
- NativeObject.Internals.debugMemory(this, "REMOVING TOGGLE %s %s");
+ debugMemory(this, "REMOVING TOGGLE %s %s%n");
/* Take away the toggle reference */
GObjectAPI.gobj.g_object_remove_toggle_ref(getNativeAddress(), toggle, objectID);
}
@@ -294,7 +310,7 @@
if (o == null) {
return;
}
- NativeObject.Internals.debugMemory(o, "TOGGLE %s %d %s", is_last_ref);
+ debugMemory(o, "TOGGLE NOTIFY %s %s %s%n", is_last_ref);
if (is_last_ref) {
strongReferences.remove(o);
} else {
@@ -307,7 +323,7 @@
@Override
public void callback(Pointer data, Pointer obj) {
GObject o = (GObject) Internals.instanceFor(obj);
- NativeObject.Internals.debugMemory(o, "WEAK %s %s obj=%s", o, obj);
+ debugMemory(o, "WEAK %s %s obj=%s%n", o, obj);
// Clear out the signal handler references
if (o == null)
return;
Modified: trunk/src/org/gnome/gir/gobject/NativeObject.java
==============================================================================
--- trunk/src/org/gnome/gir/gobject/NativeObject.java (original)
+++ trunk/src/org/gnome/gir/gobject/NativeObject.java Mon Nov 17 02:05:02 2008
@@ -128,20 +128,11 @@
debugMemory = System.getProperty("jgir.debugMemory") != null;
}
- public static final void debugMemory(GObject obj, String fmt, Object... args) {
- if (debugMemory) {
- Object[] newArgs = new Object[args.length+2];
- System.arraycopy(args, 0, newArgs, 1, args.length);
- newArgs[0] = obj;
- if (obj != null) {
- GObjectStruct objStruct = new GObjectAPI.GObjectStruct(obj);
- newArgs[newArgs.length-1] = objStruct.ref_count;
- } else {
- newArgs[newArgs.length-1] = "<null>";
- }
- System.err.println(String.format(fmt, newArgs));
- }
- }
+ public static void debugMemory(String fmt, Object...args) {
+ if (!debugMemory)
+ return;
+ System.err.printf(fmt, args);
+ }
protected static NativeObject instanceFor(Pointer ptr) {
WeakReference<NativeObject> ref = NativeObject.instanceMap.get(ptr);
Modified: trunk/src/org/gnome/gir/gobject/RefCountedObject.java
==============================================================================
--- trunk/src/org/gnome/gir/gobject/RefCountedObject.java (original)
+++ trunk/src/org/gnome/gir/gobject/RefCountedObject.java Mon Nov 17 02:05:02 2008
@@ -63,6 +63,7 @@
@Override
protected void finalize() throws Throwable {
+ NativeObject.Internals.debugMemory("UNREF %s%n", this);
unref();
super.finalize();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]