Bug 203922 - Memory leak when calling Kross::Object::callMethod
Summary: Memory leak when calling Kross::Object::callMethod
Status: RESOLVED FIXED
Alias: None
Product: bindings
Classification: Unmaintained
Component: general (other bugs)
Version First Reported In: unspecified
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Sebastian Sauer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-08-15 10:50 UTC by Joris Guisson
Modified: 2024-05-06 17:55 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joris Guisson 2009-08-15 10:50:31 UTC
Version:            (using KDE 4.3.0)
OS:                Linux
Installed from:    Ubuntu Packages

KTorrent with a python kross script, ktorrent calls a method of a class in the script through a Kross::Object::Ptr. The call is done frequently and every few seconds about 100 KB is added to the memory ktorrent is using.

How to reproduce: startup ktorrent, load a torrent, load the scripting plugin, enable the tracker grouping script. In the groups tree select a tracker group, and then just wait, and watch memory usage go up.

This is the code in ktorrent which calls the method:

bool ScriptableGroup::isMember(bt::TorrentInterface* tor)
{
	QVariantList args;
	QObject* obj = api->torrent(tor->getInfoHash().toString());
	if (!obj)
		return false;
		
	args << qVariantFromValue(obj);
	QVariant ret = script->callMethod("isMember",args);
	return ret.toBool();
}

See plugins/scripting/api/scriptablegroup.cpp in the ktorrent code.

Commenting out the script->callMethod line and making the function return true, results in no memory leaks, so this is leaking, only I don't see anything obvious what is causing it in my code, so it must be in the kross python code.
Comment 1 Joris Guisson 2009-08-15 10:53:13 UTC
Why in bugzilla is kross a component of kdevplatform ? This isn't a kdevelop bug.
Comment 2 Andreas Pakulat 2009-08-15 11:30:17 UTC
(In reply to comment #1)
> Why in bugzilla is kross a component of kdevplatform ? This isn't a kdevelop
> bug.

Because kdevplatform has kross support. If you want the kross stuff in kdelibs you need to use kdelibs as product.
Comment 3 Joris Guisson 2009-11-10 18:14:01 UTC
It seems krosspython is in kdebindings, reassigning to bindings
Comment 4 Joris Guisson 2009-11-10 19:17:13 UTC
Relevant valgrind output:

==23249== 2,112 bytes in 132 blocks are possibly lost in loss record 96 of 332
==23249==    at 0x40269EE: operator new(unsigned int) (vg_replace_malloc.c:224)
==23249==    by 0xB5D702E: Kross::PythonType<QVariant, Py::Object>::toPyObject(QVariant const&) (pythonvariant.cpp:195)
==23249==    by 0xB5FFF37: Kross::PythonObject::callMethod(QString const&, QList<QVariant> const&) (pythonvariant.h:296)
==23249==    by 0xB44CD82: kt::ScriptableGroup::isMember(bt::TorrentInterface*) (scriptablegroup.cpp:49)
==23249==    by 0x808F4AC: kt::ViewModel::Item::member(kt::Group*) const (viewmodel.cpp:299)
==23249==    by 0x80935FE: kt::ViewModel::update(kt::ViewDelegate*, bool) (viewmodel.cpp:370)
==23249==    by 0x808CBE1: kt::View::update() (view.cpp:141)
==23249==    by 0x809C605: kt::ViewManager::update() (viewmanager.cpp:218)
==23249==    by 0x80A0B5B: kt::TorrentActivity::update() (torrentactivity.cpp:243)
==23249==    by 0x8083E77: kt::GUI::update() (gui.cpp:476)
==23249==    by 0x8087914: kt::GUI::qt_metacall(QMetaObject::Call, int, void**) (gui.moc:120)
==23249==    by 0x4ECC1B7: QMetaObject::activate(QObject*, int, int, void**) (qobject.cpp:3113)
Comment 5 Sebastian Sauer 2010-04-10 23:45:18 UTC
assign to me
Comment 6 Joris Guisson 2010-04-11 11:18:38 UTC
It happens when you add a QObject pointer to the argument list of callMethod
Comment 7 Sebastian Sauer 2010-04-12 19:52:04 UTC
I see the problem. Guess we need to guard the python object better.
Comment 8 Alexey Shildyakov 2010-10-31 20:55:14 UTC
Any news in solution of this problem?
Comment 9 Matija Šuklje 2011-01-09 11:40:40 UTC
Shameless bump — is there any plan on solving this?

I mean KrossPython is quite a common scripting option in KDE for all sorts of things (KTorrent, Plasmoids etc.)
Comment 10 Justin Zobel 2021-03-09 05:24:39 UTC
Thank you for the bug report.

As this report hasn't seen any changes in 5 years or more, we ask if you can please confirm that the issue still persists.

If this bug is no longer persisting or relevant please change the status to resolved.
Comment 11 Christoph Cullmann 2024-05-06 17:55:09 UTC
Kross got removed in KF6, that solves this, naturally no like anticipated, but
that never took of, sorry.