[C++-sig] Custom memory management

Eric Jardim ericjardim at gmail.com
Fri Jul 29 16:28:57 CEST 2005


Hi,
as you may know I am wrapping the Qt4 library. 

Things are going well, but sometimes when the application ends it 
seg_faults.

The problem is that Qt has a light "garbage collection" scheme. Every 
"QObject" object that you create must has a "parent" object (except 
toplevels). When the object is deleted, it clean all the mess of its 
children and so on.

Maybe, child objects are beeing killed too soon and the parents can't find 
them. I am using the with custodian and ward at the constructors, but 
sometimes I do not create the object.

Besides, I suspect that I reference the same C++ object more than one time 
which might be a problem.

Any ideas of what I can do to manage this memory problem? I dropped here the 
backtrace of one the segfaults.

#0 0xb7eda0bd in mallopt () from /lib/tls/libc.so.6
#1 0xb7ed98fb in mallopt () from /lib/tls/libc.so.6
#2 0xb7eda2e6 in mallopt () from /lib/tls/libc.so.6
#3 0xb7ed8f02 in realloc () from /lib/tls/libc.so.6
#4 0xb721739d in qRealloc (ptr=0x821da28, size=512) at 
global/qglobal.cpp:1098
#5 0xb7232797 in QListData::realloc (this=0x821ba00, alloc=123) at 
tools/qlistdata.cpp:73
#6 0xb7232ad4 in QListData::prepend (this=0x821ba00) at 
tools/qlistdata.cpp:115
#7 0xb72c8a2b in QList<int>::prepend (this=0x821ba00, t=@0xbffff480) at 
qlist.h:408
#8 0xb72c3cac in QConnectionList::remove (this=0x821b9f0, object=0x8266808)
at kernel/qobject.cpp:174
#9 0xb72c66b6 in ~QObject (this=0x8266808) at kernel/qobject.cpp:642
#10 0xb72a9e95 in ~QAbstractItemModel (this=0x8266808) at 
kernel/qabstractitemmodel.cpp:887
#11 0xb72aa4fb in ~QAbstractListModel (this=0x8266808) at 
kernel/qabstractitemmodel.cpp:1975
#12 0xb79e8139 in ~QListModel (this=0x8266808) at 
itemviews/qlistwidget.cpp:102
#13 0xb76ab867 in ~QWidget (this=0x8253518) at kernel/qwidget.cpp:898
#14 0xb78c91e7 in ~QFrame (this=0x8253518) at widgets/qframe.cpp:209
#15 0xb7948777 in ~QAbstractScrollArea (this=0x8253518) at 
widgets/qabstractscrollarea.cpp:209
#16 0xb79a1ed7 in ~QAbstractItemView (this=0x8253518) at 
itemviews/qabstractitemview.cpp:408
#17 0xb79b445b in ~QListView (this=0x8253518) at itemviews/qlistview.cpp:247
#18 0xb79e4923 in ~QListWidget (this=0x8253518) at 
itemviews/qlistwidget.cpp:982
#19 0xb76ab093 in ~QWidget (this=0x8240be0) at kernel/qwidget.cpp:898
#20 0xb7d85e92 in ~auto_ptr (this=0xb7de7f2c) at memory:259
#21 0xb7d8694b in ~pointer_holder (this=0xb7de7f24) at pointer_holder.hpp:55
#22 0xb7ccfb2b in boost::python::instance_holder::instance_holder ()
from /usr/lib/libboost_python-gcc-mt-1_33.so.1.33.0
... there are more backtraces but are just like "0x000000 in ?? ()"

Thanks,

[Eric Jardim]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20050729/0cf9030a/attachment.htm>


More information about the Cplusplus-sig mailing list