Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak when switching between chats. #11

Closed
MeanEYE opened this issue Feb 6, 2019 · 7 comments
Closed

Memory leak when switching between chats. #11

MeanEYE opened this issue Feb 6, 2019 · 7 comments

Comments

@MeanEYE
Copy link

MeanEYE commented Feb 6, 2019

System:

  • Nheko 0.6.1
  • Installation method: Main repository
  • Operating System: Debian Testing
  • Desktop Environment: Gnome Shell (Wayland)

Actual behavior

Switching between chats constantly eats memory.

Expected behavior

Not eating memory.

Steps to reproduce

Switch between two chats for a while.

@MeanEYE
Copy link
Author

MeanEYE commented Feb 6, 2019

I do realize this is an old version, before this project existed, but reporting on old repository will not result in any fixes and since the code base for the most part is the same, I thought this might be relevant.

@redsky17
Copy link
Member

redsky17 commented Feb 7, 2019

Are you noticing this when switching back and forth from the same two chats, or when switching between various other chats? nheko has some built-in caching of messages to prevent the need to re-request them from the server all the time. I just want to verify what you mean by the 'Switch between two chats for a while' portion of the issue.

@MeanEYE
Copy link
Author

MeanEYE commented Feb 11, 2019

I tested with same two chats as that way it's easier to replicate the behavior and can't be attributed to just loading new history into memory.

Example before test, with both top chats loaded once:
image

After switching between the top two chats 10+ times:
image

@MeanEYE
Copy link
Author

MeanEYE commented Feb 11, 2019

Please note that here difference is not as drastic as in some previous cases I ran into this issues. This might be something to do with the fact I restarted application before testing so that other chats don't affect the outcome.

If the application has longer uptime, I think results should be more drastic. However I don't have images of this, but I can test for that if you wish.

@redsky17
Copy link
Member

Is there any chance you can run valgrind on nheko while you're doing this, and share the output file with me? I did this on my end, but wasn't able to see any memory leaks after a few minutes of switching back and forth.

This command should be sufficient:

valgrind --leak-check=full --show-leak-kinds=all /path/to/nheko

Nheko does run much slower under valgrind, just as an fyi.

If you can't run valgrind, let me know.

@MeanEYE
Copy link
Author

MeanEYE commented Feb 12, 2019

nheko-report.txt

Here it is.

@deepbluev7
Copy link
Member

I think this shouldn't be an issue anymore, since before we used widgets for the timeline, that were never freed. Now we use qml to dynamically generate the timeline view, which uses a bit of memory for caches, but should have an upper limit (apart from all the messages still being kept in memory, as we don't drop them from the in memory cache. That overhead should be reasonably minimal and should go away, once we actually use a proper disk cache for all messages in the future.)

deepbluev7 added a commit that referenced this issue Dec 17, 2022
Backtrace:

Thread 1 "nheko" received signal SIGSEGV, Segmentation fault.
containerWidget (w=w@entry=0x0) at /usr/src/debug/dev-qt/qtwidgets-5.15.7/qtbase-everywhere-src-5.15.7/src/widgets/styles/qstylesheetstyle.cpp:2467
2467        if (const QAbstractScrollArea *sa = qobject_cast<const QAbstractScrollArea *>(w->parentWidget())) {
(gdb) bt
 #0  containerWidget(QWidget const*) (w=w@entry=0x0) at /usr/src/debug/dev-qt/qtwidgets-5.15.7/qtbase-everywhere-src-5.15.7/src/widgets/styles/qstylesheetstyle.cpp:2467
 #1  0x00007ffff4aa0ad6 in QStyleSheetStyle::drawPrimitive(QStyle::PrimitiveElement, QStyleOption const*, QPainter*, QWidget const*) const (this=0x555559917900, pe=<optimized out>, opt=0x55555ea4b5c0, p=0x7fffffffcfd0, w=0x0) at /usr/src/debug/dev-qt/qtwidgets-5.15.7/qtbase-everywhere-src-5.15.7/src/widgets/styles/qstylesheetstyle.cpp:4452
 #2  0x00007fff61d4a86b in KQuickStyleItem::paint(QPainter*) (this=this@entry=0x55555ea4a1e0, painter=painter@entry=0x7fffffffcfd0) at /usr/src/debug/kde-frameworks/qqc2-desktop-style-5.101.0/qqc2-desktop-style-5.101.0/plugin/kquickstyleitem.cpp:1667
 #3  0x00007fff61d4b22a in KQuickStyleItem::updatePolish() (this=0x55555ea4a1e0) at /usr/src/debug/kde-frameworks/qqc2-desktop-style-5.101.0/qqc2-desktop-style-5.101.0/plugin/kquickstyleitem.cpp:1928
 #4  0x00007ffff57717c2 in QQuickWindowPrivate::polishItems() (this=0x55555ea2e760) at /usr/src/debug/dev-qt/qtdeclarative-5.15.7-r1/qtdeclarative-everywhere-src-5.15.7/src/quick/items/qquickwindow.cpp:393
 #5  0x00007ffff570f4ef in QSGThreadedRenderLoop::polishAndSync(QSGThreadedRenderLoop::Window*, bool) (this=this@entry=0x5555598eb770, w=w@entry=0x7fffe000aef0, inExpose=inExpose@entry=true) at /usr/src/debug/dev-qt/qtdeclarative-5.15.7-r1/qtdeclarative-everywhere-src-5.15.7/src/quick/scenegraph/qsgthreadedrenderloop.cpp:1576
 #6  0x00007ffff5710a8e in QSGThreadedRenderLoop::handleExposure(QQuickWindow*) (this=0x5555598eb770, window=<optimized out>) at /usr/src/debug/dev-qt/qtdeclarative-5.15.7-r1/qtdeclarative-everywhere-src-5.15.7/src/quick/scenegraph/qsgthreadedrenderloop.cpp:1374
 #7  0x00007ffff43d2b45 in QWindow::event(QEvent*) (this=0x7fffe0006eb0, ev=<optimized out>) at /usr/src/debug/dev-qt/qtgui-5.15.7-r1/qtbase-everywhere-src-5.15.7/src/gui/kernel/qwindow.cpp:2450
 #8  0x00007ffff49ee481 in QApplicationPrivate::notify_helper(QObject*, QEvent*) (this=<optimized out>, receiver=0x7fffe0006eb0, e=0x7fffffffd460) at /usr/src/debug/dev-qt/qtwidgets-5.15.7/qtbase-everywhere-src-5.15.7/src/widgets/kernel/qapplication.cpp:3637
 #9  0x00007ffff3e2d618 in QCoreApplication::notifyInternal2(QObject*, QEvent*) (receiver=0x7fffe0006eb0, event=0x7fffffffd460) at /usr/src/debug/dev-qt/qtcore-5.15.7/qtbase-everywhere-src-5.15.7/src/corelib/kernel/qcoreapplication.cpp:1064
 #10 0x00007ffff43c8368 in QGuiApplicationPrivate::processExposeEvent(QWindowSystemInterfacePrivate::ExposeEvent*) (e=0x55555f648b30) at /usr/src/debug/dev-qt/qtgui-5.15.7-r1/qtbase-everywhere-src-5.15.7/src/gui/kernel/qguiapplication.cpp:3261
 #11 0x00007ffff43a55ab in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) (flags=flags@entry=...) at /usr/src/debug/dev-qt/qtgui-5.15.7-r1/qtbase-everywhere-src-5.15.7/src/gui/kernel/qwindowsysteminterface.cpp:1169
 #12 0x00007fffef102622 in xcbSourceDispatch(GSource*, GSourceFunc, gpointer) (source=<optimized out>) at /usr/src/debug/dev-qt/qtgui-5.15.7-r1/qtbase-everywhere-src-5.15.7/src/plugins/platforms/xcb/qxcbeventdispatcher.cpp:105
 #13 0x00007ffff386d030 in g_main_context_dispatch () at /usr/lib64/libglib-2.0.so.0
 #14 0x00007ffff386d2d8 in  () at /usr/lib64/libglib-2.0.so.0
 #15 0x00007ffff386d36f in g_main_context_iteration () at /usr/lib64/libglib-2.0.so.0
 #16 0x00007ffff3e80e55 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) (this=0x5555596a4770, flags=...) at /usr/src/debug/dev-qt/qtcore-5.15.7/qtbase-everywhere-src-5.15.7/src/corelib/kernel/qeventdispatcher_glib.cpp:423
 #17 0x00007ffff3e2c00b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) (this=this@entry=0x7fffffffd700, flags=..., flags@entry=...) at /usr/src/debug/dev-qt/qtcore-5.15.7/qtbase-everywhere-src-5.15.7/include/QtCore/../../src/corelib/global/qflags.h:69
 #18 0x00007ffff3e344ea in QCoreApplication::exec() () at /usr/src/debug/dev-qt/qtcore-5.15.7/qtbase-everywhere-src-5.15.7/include/QtCore/../../src/corelib/global/qflags.h:121
 #19 0x00005555594a5c43 in main(int, char**) (argc=2, argv=0x7fffffffdab8) at /home/nicolas/Dokumente/devel/open-source/nheko/src/main.cpp:401
(gdb) p w
$1 = (const QWidget *) 0x0
Lymkwi pushed a commit to Lymkwi/nheko that referenced this issue May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants