[Konsole-devel] Review Request: patch to reduce memory usage for fixed-size history in konsole

mick22 at gmx.at mick22 at gmx.at
Wed Jun 17 23:22:24 UTC 2009

This is an automatically generated e-mail. To reply, visit:

(Updated 2009-06-17 16:22:24.013010)

Review request for Konsole.


Yet another version of the patch. As it turned out during the discussion of bug 176974, the data size of konsole seldom shrinks (probably due to heap fragmentation), even if the history is cleared or a tab is closed. This might seem like a memory leak to some users, even though valgrind does not show leaks in the history code.

This version of the patch uses a simple custom memory pool (implemented as a list of mmap'ed blocks) to allocate memory for history lines.

To keep things simple, the two types of history lines of previous patch versions (single- and multi-color) are no longer used, as mem allocation is cheaper now anyway.


Here's a patch that drastically reduces mem usage when a fixed size history is
- new history storage type "HistoryTypeQList"  (QList-based) set as replacement for HistoryTypeBuffer
- compact storage for history lines

History lines are stored as an array of chars when possible (i.e. when
color and rendition flag of all characters in the line are equal). 2 bytes per character + overhead

When not (easily) possible, it falls back to the current way of storing history lines (array of QVector<Character>). 11 bytes per character + overhead

Memory usage has been cut down from about 171MB to 55MB for a konsole process
with 5 tabs, 30000 lines scrollback, 65 chars per line.

As suggested in https://bugs.kde.org/show_bug.cgi?id=176974#c20, a formatting array has been introduced in v2 of the patch. The CompactHistoryLine class can now handle single- and multi-color history lines. This replaces v1 of the patch where 2 separate classes were used.

This addresses bug 176974.

Diffs (updated)

  /trunk/KDE/kdebase/apps/konsole/src/Character.h 981222 
  /trunk/KDE/kdebase/apps/konsole/src/History.h 981222 
  /trunk/KDE/kdebase/apps/konsole/src/History.cpp 981222 
  /trunk/KDE/kdebase/apps/konsole/src/SessionController.cpp 981222 
  /trunk/KDE/kdebase/apps/konsole/src/SessionManager.cpp 981222 

Diff: http://reviewboard.kde.org/r/802/diff


reasonably tested 



More information about the konsole-devel mailing list