aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@theqtcompany.com>2014-10-27 13:51:27 +0100
committerSimon Hausmann <simon.hausmann@digia.com>2014-10-27 15:19:15 +0100
commit327d0886c3d9e9854849f5bebda4d6825e94a62e (patch)
tree43aff65ead92aefcdece2e34edaf6769b38dcc4e /src
parent57e5407178ce05f577bd032a7bab2508434a4b02 (diff)
Reduce memory pressure on system malloc when allocating large items on the GC heap
Try to free our large items for every 8 megabytes of additional large item memory we allocate. This helps in particular on 32-bit builds and was noticable in tst_qqmlecmascript::push_and_shift(). Change-Id: I4cc0b188e58ccaf32026e38c7aaf1cfadc83148b Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/qml/jsruntime/qv4mm.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/qml/jsruntime/qv4mm.cpp b/src/qml/jsruntime/qv4mm.cpp
index 442a27661b..b9a4a55b4a 100644
--- a/src/qml/jsruntime/qv4mm.cpp
+++ b/src/qml/jsruntime/qv4mm.cpp
@@ -104,6 +104,7 @@ struct MemoryManager::Data
};
LargeItem *largeItems;
+ std::size_t totalLargeItemsAllocated;
GCDeletable *deletable;
@@ -120,6 +121,7 @@ struct MemoryManager::Data
, maxShift(6)
, maxChunkSize(32*1024)
, largeItems(0)
+ , totalLargeItemsAllocated(0)
, deletable(0)
{
memset(smallItems, 0, sizeof(smallItems));
@@ -185,6 +187,9 @@ Managed *MemoryManager::allocData(std::size_t size)
// doesn't fit into a small bucket
if (size >= MemoryManager::Data::MaxItemSize) {
+ if (m_d->totalLargeItemsAllocated > 8 * 1024 * 1024)
+ runGC();
+
// we use malloc for this
MemoryManager::Data::LargeItem *item = static_cast<MemoryManager::Data::LargeItem *>(
malloc(Q_V4_PROFILE_ALLOC(m_d->engine, size + sizeof(MemoryManager::Data::LargeItem),
@@ -193,6 +198,7 @@ Managed *MemoryManager::allocData(std::size_t size)
item->next = m_d->largeItems;
item->size = size;
m_d->largeItems = item;
+ m_d->totalLargeItemsAllocated += size;
return item->managed();
}
@@ -476,6 +482,7 @@ void MemoryManager::runGC()
memset(m_d->allocCount, 0, sizeof(m_d->allocCount));
m_d->totalAlloc = 0;
+ m_d->totalLargeItemsAllocated = 0;
}
size_t MemoryManager::getUsedMem() const