Version: 0.4 (using KDE KDE 3.4.0) Installed from: Gentoo Packages Compiler: gcc-3.3.5 OS: Linux While doing some tex, I used kpdf to view the results. Using "Watch File" it is reloading the file, when it changed. Somehow, it consumes more and more memory (perhaps it keeps the old versions?). I'm not sure about the result of top (X?), so I just paste it here. PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 11506 root 15 0 304m 148m 140m S 7.7 14.6 166:59.66 X 26966 me 15 0 107m 62m 31m S 0.3 6.2 0:39.33 kpdf After closing kpdf: PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 11506 root 15 0 226m 70m 140m S 0.3 7.0 167:00.54 X This is the memory usage after some reloads, working a bit longer it consumes some 100mb!
CVS commit by aacid: Comitting a fix for the memory leak that happens when reloading a file because it was beign watched. To fix it what we do is close the document, show a message telling that the document is beign reloaded and then open the document again when it's ready, that presents a big problem to a backport, because without the text it is really not understood that something is happening. Enrico any idea to do this in a better way so we can backport it? BUGS: 101192 M +17 -4 part.cpp 1.30 M +2 -1 part.h 1.11 M +7 -0 ui/pageview.cpp 1.49 M +2 -0 ui/pageview.h 1.17 --- kdegraphics/kpdf/part.cpp #1.29:1.30 @@ -357,4 +357,6 @@ bool Part::openURL(const KURL &url) if ( !b ) KMessageBox::error( widget(), i18n("Could not open %1").arg( url.prettyURL() ) ); + else + m_viewportDirty.pageNumber = -1; return b; } @@ -403,9 +405,20 @@ void Part::slotFileDirty( const QString& void Part::slotDoFileDirty() { - uint p = m_document->currentPage() + 1; - if (openFile()) + if (m_viewportDirty.pageNumber == -1) { - if (p > m_document->pages()) p = m_document->pages(); - goToPage(p); + m_viewportDirty = m_document->viewport(); + m_pageView->showText(i18n("Reloading the document..."), 0); + } + + if (KParts::ReadOnlyPart::openURL(m_file)) + { + if (m_viewportDirty.pageNumber > m_document->pages()) m_viewportDirty.pageNumber = m_document->pages(); + m_document->setViewport(m_viewportDirty); + m_viewportDirty.pageNumber = -1; + } + else + { + m_watcher->addFile(m_file); + m_dirtyHandler->start( 750, true ); } } --- kdegraphics/kpdf/part.h #1.10:1.11 @@ -20,4 +20,5 @@ #include <kparts/part.h> #include <qguardedptr.h> +#include "core/document.h" #include "core/observer.h" #include "dcop.h" @@ -36,5 +37,4 @@ class KAboutData; class KPrinter; -class KPDFDocument; class ThumbnailList; class ThumbnailController; @@ -134,4 +134,5 @@ private: KDirWatch *m_watcher; QTimer *m_dirtyHandler; + DocumentViewport m_viewportDirty; // actions --- kdegraphics/kpdf/ui/pageview.cpp #1.48:1.49 @@ -404,4 +404,11 @@ bool PageView::canUnloadPixmap( int page //END DocumentObserver inherited methods + +void PageView::showText( const QString &text, int ms ) +{ + d->messageWindow->display(text, PageViewMessage::Info, ms ); +} + + //BEGIN widget events void PageView::viewportPaintEvent( QPaintEvent * pe ) --- kdegraphics/kpdf/ui/pageview.h #1.16:1.17 @@ -64,4 +64,6 @@ class PageView : public QScrollView, pub bool canUnloadPixmap( int pageNum ); + void showText( const QString &text, int ms ); + signals: void urlDropped( const KURL& );
Verified :) Thx for the fast fix!!! To the backport: You could introduce a statusbar, showing all information displayed in the message box of the newer versions (if this is not too much for a backport).
The problem is not the message box but the text itself, in "old" branches like KDE 3.4.x new texts are not allowed :-( and without "Reloading the document..." it is pretty difficult to see the document is actually beign reloaded.
*** Bug 101265 has been marked as a duplicate of this bug. ***
How about a backport that shows the filename of the file being reloaded instead of i18n("Reloading the document..."). Might be still unclear but maybe better than the memory leak. And it does not need translation. Just an idea... Keep up that great work...
I've backported the fix with the translation asked at translators list and got an OK