Reduce KFileItemModel memory usage by implicitly sharing QByteArrays
Review Request #110686 - Created May 28, 2013 and submitted
The summary says it all. The idea is based on http://milianw.de/blog/katekdevelop-sprint-vienna-2012-take-1
Opened a directory with 100000 files with the default view properties. Memory usage as reported by ksysguard is reduced from 309 MB to 280.5 MB.
Hi Frank, I noticed this ticket and took a small nose dive in string optimization. Your approach (as well as the kmail version) is simple and effective, that's for sure! However, i think it can be done even more effective. If you would do the same only using a Trie (http://en.wikipedia.org/wiki/Trie or one of it's variants) then you would gain a whole lot more. Then you get very cheap string completion when searching (or typing in the url bar) and the memory usage will go down even more. Funnily enough, Qt (or actually Qt Creator) has a documented Trie implementation: http://doc-snapshot.qt-project.org/qtcreator-extending/qmljs-persistenttrie-trie.html The downside is that you can't use it directly. You would have to copy the class either into dolphin or into kdelibs from frameworks (which would make it pointless for the current dolphin). It's quite a bummer that Qt doesn't come with a Trie like class naively. I'm guessing you won't go this route due to more files to maintain, but it certainly is worth to take a look at it :)