dcsimg
Linux Today: Linux News On Internet Time.





news.kde.org: C++ and shared libraries

Sep 20, 2001, 17:26 (27 Talkback[s])

From news.kde.org:

"I was recently hired by SuSE to focus on optimizing KDE, and as part of my work, I have written an analysis of KDE memory usage based on Waldo Bastian's previous paper concerning GNU/Linux linker issues and KDE startup-performance. As it turns out, the linker issues examined by Waldo do indeed have an effect on the memory usage of C++ applications compiled and linked under GNU/Linux. The most important number from this paper: About 650KB of memory wasted per KDE application not launched via KDE Init."

[ More links and information on the issue available at news.kde.org. Analysis linked below. -ed. ]

"In theory, C++ is as efficient (both in memory and speed) as C, C++ features that have no direct equivalent in C are as efficient as equivalent hand-written code in C implementing the same feature, and C++ features that are not used don't cause any overhead.

In theory, shared libraries are completely shared by all programs (processes) using them, without needing any additional memory - more memory should be needed only if some functionality in the library is used and is needed for this functionality.

Unfortunately, neither of these two assumptions is true in practice. When using gcc/GNU ld/glibc in projects like KDE where large C++ libraries are used, the overhead may become significant, because of gcc/GNU ld/glibc inefficient handling of large C++ libraries.

In this document, I'll try to analyze some of the reasons why large C++ libraries cause so much overhead. Before reading this document, you should first read Waldo Bastian's document about certain linker problems ( http://www.suse.de/~bastian/Export/linking.txt ), which is mainly aimed at slow startup of applications using large C++ libraries. In this document, the speed aspects are ignored, as the speed problems seem to be fixed by a prelink tool that's under development. Instead, this document focuses on increased memory usage of applications using large C++ libraries, caused by these libraries."

Complete Story

Related Stories: