summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2014-07-15 12:58:17 +0100
committerCaolán McNamara <caolanm@redhat.com>2014-07-15 16:15:17 +0100
commit60de576a295682002c59b90b1429da25bcd854ea (patch)
tree306b1870c3f82acc8742e6e7966502e965e907ca /svtools
parent0ca0202a0994c0b7c99c366fd5cafd8a655df203 (diff)
use same swap stategy on all platforms
Change-Id: I565dfd9233088feae69de6261d1081fc51f10806
Diffstat (limited to 'svtools')
-rw-r--r--svtools/source/graphic/grfmgr2.cxx82
1 files changed, 39 insertions, 43 deletions
diff --git a/svtools/source/graphic/grfmgr2.cxx b/svtools/source/graphic/grfmgr2.cxx
index d5731d8cde9a..3db61617799a 100644
--- a/svtools/source/graphic/grfmgr2.cxx
+++ b/svtools/source/graphic/grfmgr2.cxx
@@ -189,60 +189,56 @@ namespace
void GraphicManager::ImplCheckSizeOfSwappedInGraphics()
{
- // only necessary for 32bit systems
- if(SAL_TYPES_SIZEOFPOINTER <= 4)
+ // get the currently used memory footprint of all swapped in bitmap graphics
+ // of this graphic manager. Remember candidates in a vector. The size in bytes is
+ // already available, thus this loop is not expensive to execute
+ sal_uLong nUsedSize(0);
+ GraphicObject* pObj = 0;
+ std::vector< GraphicObject* > aCandidates;
+
+ for (size_t i = 0, n = maObjList.size(); i < n; ++i)
{
- // get the currently used memory footprint of all swapped in bitmap graphics
- // of this graphic manager. Remember candidates in a vector. The size in bytes is
- // already available, thus this loop is not expensive to execute
- sal_uLong nUsedSize(0);
- GraphicObject* pObj = 0;
- std::vector< GraphicObject* > aCandidates;
-
- for (size_t i = 0, n = maObjList.size(); i < n; ++i)
+ pObj = maObjList[i];
+ if (pObj->meType == GRAPHIC_BITMAP && !pObj->IsSwappedOut() && pObj->GetSizeBytes())
{
- pObj = maObjList[i];
- if (pObj->meType == GRAPHIC_BITMAP && !pObj->IsSwappedOut() && pObj->GetSizeBytes())
- {
- aCandidates.push_back(pObj);
- nUsedSize += pObj->GetSizeBytes();
- }
+ aCandidates.push_back(pObj);
+ nUsedSize += pObj->GetSizeBytes();
}
+ }
+
+ // detect maximum allowed memory footprint. Use the user-settings of MaxCacheSize (defaulted
+ // to 20MB) and add a decent multiplicator (experimented to find one). Limit to
+ // a useful maximum for 32Bit address space
- // detect maximum allowed memory footprint. Use the user-settings of MaxCacheSize (defaulted
- // to 20MB) and add a decent multiplicator (expecrimented to find one). Limit to
- // a useful maximum for 32Bit address space
+ // default is 20MB, so allow 200MB initially
+ static sal_uLong aMultiplicator(10);
- // default is 20MB, so allow 200MB initially
- static sal_uLong aMultiplicator(10);
+ // max at 500MB; I experimented with 800 for debug and 750 for non-debug settings (pics start
+ // missing when office reaches a mem footprint of 1.5GB) but some secure left over space for
+ // app activity is needed
+ static sal_uLong aMaxSize32Bit(500 * 1024 * 1024);
- // max at 500MB; I experimented with 800 for debug and 750 for non-debug settings (pics start
- // missing when office reaches a mem footprint of 1.5GB) but some secure left over space for
- // app activity is needed
- static sal_uLong aMaxSize32Bit(500 * 1024 * 1024);
+ // calc max allowed cache size
+ const sal_uLong nMaxCacheSize(::std::min(GetMaxCacheSize() * aMultiplicator, aMaxSize32Bit));
- // calc max allowed cache size
- const sal_uLong nMaxCacheSize(::std::min(GetMaxCacheSize() * aMultiplicator, aMaxSize32Bit));
+ if(nUsedSize >= nMaxCacheSize && !aCandidates.empty())
+ {
+ // if we use more currently, sort by last DataChangeTimeStamp
+ // sort by DataChangeTimeStamp so that the oldest get removed first
+ ::std::sort(aCandidates.begin(), aCandidates.end(), simpleSortByDataChangeTimeStamp());
- if(nUsedSize >= nMaxCacheSize && !aCandidates.empty())
+ for(sal_uInt32 a(0); nUsedSize >= nMaxCacheSize && a < aCandidates.size(); a++)
{
- // if we use more currently, sort by last DataChangeTimeStamp
- // sort by DataChangeTimeStamp so that the oldest get removed first
- ::std::sort(aCandidates.begin(), aCandidates.end(), simpleSortByDataChangeTimeStamp());
+ // swap out until we have no more or the goal to use less than nMaxCacheSize
+ // is reached
+ pObj = aCandidates[a];
+ const sal_uLong nSizeBytes(pObj->GetSizeBytes());
- for(sal_uInt32 a(0); nUsedSize >= nMaxCacheSize && a < aCandidates.size(); a++)
+ // do not swap out when we have less than 16KB data objects
+ if(nSizeBytes >= (16 * 1024))
{
- // swap out until we have no more or the goal to use less than nMaxCacheSize
- // is reached
- pObj = aCandidates[a];
- const sal_uLong nSizeBytes(pObj->GetSizeBytes());
-
- // do not swap out when we have less than 16KB data objects
- if(nSizeBytes >= (16 * 1024))
- {
- pObj->FireSwapOutRequest();
- nUsedSize = (nSizeBytes < nUsedSize) ? nUsedSize - nSizeBytes : 0;
- }
+ pObj->FireSwapOutRequest();
+ nUsedSize = (nSizeBytes < nUsedSize) ? nUsedSize - nSizeBytes : 0;
}
}
}