mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-23 18:32:50 +00:00
plasma: do not enlarge the pixmap cache size
this needs a config knob like the theme cache size Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
547ccac0f8
commit
2f5c1e72ef
1 changed files with 0 additions and 86 deletions
|
@ -20,24 +20,8 @@
|
|||
|
||||
#include "plasmaapp.h"
|
||||
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#ifndef _SC_PHYS_PAGES
|
||||
#if defined(Q_OS_FREEBSD) || defined(Q_OS_DRAGONFLY)
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_NETBSD
|
||||
#include <sys/param.h>
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
#include <QPixmapCache>
|
||||
#include <QtDBus/QtDBus>
|
||||
#include <QElapsedTimer>
|
||||
#include <QTimer>
|
||||
|
@ -156,76 +140,6 @@ PlasmaApp::PlasmaApp()
|
|||
new PlasmaAppAdaptor(this);
|
||||
QDBusConnection::sessionBus().registerObject("/App", this);
|
||||
|
||||
// Enlarge application pixmap cache
|
||||
// Calculate the size required to hold background pixmaps for all screens.
|
||||
// Add 10% so that other (smaller) pixmaps can also be cached.
|
||||
int cacheSize = 0;
|
||||
|
||||
if (KGlobalSettings::isMultiHead()) {
|
||||
int id = 0;
|
||||
#ifdef Q_WS_X11
|
||||
Display *dpy = XOpenDisplay(NULL);
|
||||
if (dpy) {
|
||||
id = DefaultScreen(dpy);
|
||||
XCloseDisplay(dpy);
|
||||
}
|
||||
#endif
|
||||
const QSize size = QApplication::desktop()->screenGeometry(id).size();
|
||||
cacheSize += 4 * size.width() * size.height() / 1024;
|
||||
} else {
|
||||
for (int i = 0; i < QApplication::desktop()->screenCount(); i++) {
|
||||
QSize size = QApplication::desktop()->screenGeometry(i).size();
|
||||
cacheSize += 4 * size.width() * size.height() / 1024;
|
||||
}
|
||||
}
|
||||
cacheSize += cacheSize / 10;
|
||||
|
||||
// Calculate the size of physical system memory; _SC_PHYS_PAGES *
|
||||
// _SC_PAGESIZE is documented to be able to overflow 32-bit integers,
|
||||
// so apply a 10-bit shift. FreeBSD 6-STABLE doesn't have _SC_PHYS_PAGES
|
||||
// (it is documented in FreeBSD 7-STABLE as "Solaris and Linux extension")
|
||||
// so use sysctl in those cases.
|
||||
#if defined(_SC_PHYS_PAGES)
|
||||
int memorySize = sysconf(_SC_PHYS_PAGES);
|
||||
memorySize *= sysconf(_SC_PAGESIZE) / 1024;
|
||||
#else
|
||||
#ifdef Q_OS_FREEBSD || defined(Q_OS_DRAGONFLY)
|
||||
int sysctlbuf[2];
|
||||
size_t size = sizeof(sysctlbuf);
|
||||
int memorySize;
|
||||
// This could actually use hw.physmem instead, but I can't find
|
||||
// reliable documentation on how to read the value (which may
|
||||
// not fit in a 32 bit integer).
|
||||
if (!sysctlbyname("vm.stats.vm.v_page_size", sysctlbuf, &size, NULL, 0)) {
|
||||
memorySize = sysctlbuf[0] / 1024;
|
||||
size = sizeof(sysctlbuf);
|
||||
if (!sysctlbyname("vm.stats.vm.v_page_count", sysctlbuf, &size, NULL, 0)) {
|
||||
memorySize *= sysctlbuf[0];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef Q_OS_NETBSD
|
||||
size_t memorySize;
|
||||
size_t len;
|
||||
static int mib[] = { CTL_HW, HW_PHYSMEM };
|
||||
|
||||
len = sizeof(memorySize);
|
||||
sysctl(mib, 2, &memorySize, &len, NULL, 0);
|
||||
memorySize /= 1024;
|
||||
#endif
|
||||
// If you have no suitable sysconf() interface and are not FreeBSD,
|
||||
// then you are out of luck and get a compile error.
|
||||
#endif
|
||||
|
||||
// Increase the pixmap cache size to 1% of system memory if it isn't already
|
||||
// larger so as to maximize cache usage. 1% of 1GB ~= 10MB.
|
||||
if (cacheSize < memorySize / 100) {
|
||||
cacheSize = memorySize / 100;
|
||||
}
|
||||
|
||||
kDebug() << "Setting the pixmap cache size to" << cacheSize << "kilobytes";
|
||||
QPixmapCache::setCacheLimit(cacheSize);
|
||||
|
||||
KGlobal::setAllowQuit(true);
|
||||
KGlobal::ref();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue