[Stackless-checkins] r53810 - stackless/trunk/Stackless/module/stacklessmodule.c
christian.tismer
python-checkins at python.org
Sat Feb 17 01:30:13 CET 2007
Author: christian.tismer
Date: Sat Feb 17 01:30:13 2007
New Revision: 53810
Modified:
stackless/trunk/Stackless/module/stacklessmodule.c
Log:
added tiny helpers _gc_untrack and _gc_track.
This is support for my new leak detector which
gets massively accelerated.
Modified: stackless/trunk/Stackless/module/stacklessmodule.c
==============================================================================
--- stackless/trunk/Stackless/module/stacklessmodule.c (original)
+++ stackless/trunk/Stackless/module/stacklessmodule.c Sat Feb 17 01:30:13 2007
@@ -714,6 +714,41 @@
#endif
+/******************************************************
+
+ Special support for RPython
+
+ ******************************************************/
+
+/*
+ In RPython, we are not allowed to use cyclic references
+ without explicitly breaking them, or we leak memory.
+ I wrote a tool to find out which code line causes
+ unreachable objects. It works by running a full GC run
+ after every line. To make this reasonably fast, it makes
+ sense to remove the existing GC objects temporarily.
+ */
+
+static PyObject *
+_gc_untrack(PyObject *self, PyObject *ob)
+{
+ PyObject_GC_UnTrack(ob);
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_gc_track(PyObject *self, PyObject *ob)
+{
+ PyObject_GC_Track(ob);
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static char _gc_untrack__doc__[] =
+"_gc_untrack, gc_track -- remove or add an object from the gc list.";
+
+
/* List of functions defined in the module */
#define PCF PyCFunction
@@ -748,6 +783,10 @@
slp_pickle_moduledict__doc__},
{"get_thread_info", (PCF)get_thread_info, METH_VARARGS,
get_thread_info__doc__},
+ {"_gc_untrack", (PCF)_gc_untrack, METH_O,
+ _gc_untrack__doc__},
+ {"_gc_track", (PCF)_gc_track, METH_O,
+ _gc_untrack__doc__},
#ifdef STACKLESS_SPY
{"_peek", (PCF)_peek, METH_O,
_peek__doc__},
_______________________________________________
Stackless-checkins mailing list
Stackless-checkins at stackless.com
http://www.stackless.com/mailman/listinfo/stackless-checkins
More information about the Stackless-checkins
mailing list