Hi everybody,
 
In my Jambi application I am handling lots of widgets. For example for each 
click on a QTableView the program shows (creates) an info widget displaying 
details of the selected item. Now I noticed a memory leak. I've read two 
different posts [1] and [2] on this list about memory issues and understand 
that using "dispose()" might help the GC but is not necessary in general.
You'll find a very brief example program below. On my WindowsXP machine with 
qtjambi-win32-msvc2005-4.4.0_01 this creates a memory leak when you hit the 
"Create" botton a couple of times. Note the significant difference in the 
memory leak if you invoke "leak.dispose()" every time.
 
Is there a way to avoid this memory leak?
What is the difference between dispose() and destroy() when invoked on a Jambi 
QWidget? (I noticed that invoking "leak.destroy()" doesn't do much good in my 
sample program.)
 
Any hints will be greatly appreciated,
Curt
 
 
 
[1] http://lists.trolltech.com/qt-jambi-interest/2006-11/thread00042-0.html
[2] http://lists.trolltech.com/qt-jambi-interest/2008-02/thread00008-0.html
 
 
import com.trolltech.qt.gui.QApplication;
import com.trolltech.qt.gui.QHBoxLayout;
import com.trolltech.qt.gui.QLayout;
import com.trolltech.qt.gui.QPushButton;
import com.trolltech.qt.gui.QWidget;

public class QtLeak extends QWidget{

    public static void main(String[] args) {
        QApplication.initialize(args);

        QtLeak testQtLeak = new QtLeak(null);
        testQtLeak.show();

        QApplication.exec();
    }

    public QtLeak(QWidget parent){
        super(parent);
        
        QLayout layout = new QHBoxLayout(this);
        QPushButton buttonCreate = new QPushButton("Create", this);
        buttonCreate.clicked.connect(this, "create()");        
        layout.addWidget(buttonCreate);
        
        this.setLayout(layout);
    }
    
    
    @SuppressWarnings("unused")
    private void create()
    {
        for(int i=0; i<1000; i++){
            QtLeak leak = new QtLeak(null);
//            leak.dispose();
        }
    }
}


_______________________________________________
Qt-jambi-interest mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt-jambi-interest

Reply via email to