aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2017-06-28 11:25:18 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2017-08-04 13:29:10 +0000
commita253824a258c437bf1c8c67aefd6f5f928c9dfd7 (patch)
treeff393165de35bdddb65134ee199bdd936e9f6c5c /src/qml/compiler
parent0577c9f35628ac2f63e6ce4e6fa73bb4614e29ae (diff)
Improve releasing of memory allocated from compilation unit strings
Allocate the strings in the compilation unit as regular strings, not as identifiers. We mark the runtimeStrings in the compilation unit, so when the unit is released as part of component cache trimming, those strings can also be collected. The JS object literal class keys have to remain identifiers though. However this is just a stop-gap as the real problem is that the identifier table can be triggered to grow without bounds. Task-number: QTBUG-61536 Change-Id: I7a2854b7fa9c9953348b5e34a31833f7be67cfbf Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml/compiler')
-rw-r--r--src/qml/compiler/qv4compileddata.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/qml/compiler/qv4compileddata.cpp b/src/qml/compiler/qv4compileddata.cpp
index 72b2c3fd07..8ca1a29b2a 100644
--- a/src/qml/compiler/qv4compileddata.cpp
+++ b/src/qml/compiler/qv4compileddata.cpp
@@ -57,6 +57,7 @@
#include <QScopedValueRollback>
#include <QStandardPaths>
#include <QDir>
+#include <private/qv4identifiertable_p.h>
#endif
#include <private/qqmlirbuilder_p.h>
#include <QCoreApplication>
@@ -127,7 +128,7 @@ QV4::Function *CompilationUnit::linkToEngine(ExecutionEngine *engine)
// memset the strings to 0 in case a GC run happens while we're within the loop below
memset(runtimeStrings, 0, data->stringTableSize * sizeof(QV4::Heap::String*));
for (uint i = 0; i < data->stringTableSize; ++i)
- runtimeStrings[i] = engine->newIdentifier(data->stringAt(i));
+ runtimeStrings[i] = engine->newString(data->stringAt(i));
runtimeRegularExpressions = new QV4::Value[data->regexpTableSize];
// memset the regexps to 0 in case a GC run happens while we're within the loop below
@@ -180,7 +181,7 @@ QV4::Function *CompilationUnit::linkToEngine(ExecutionEngine *engine)
const CompiledData::JSClassMember *member = data->jsClassAt(i, &memberCount);
QV4::InternalClass *klass = engine->internalClasses[QV4::ExecutionEngine::Class_Object];
for (int j = 0; j < memberCount; ++j, ++member)
- klass = klass->addMember(runtimeStrings[member->nameOffset]->identifier, member->isAccessor ? QV4::Attr_Accessor : QV4::Attr_Data);
+ klass = klass->addMember(engine->identifierTable->identifier(runtimeStrings[member->nameOffset]), member->isAccessor ? QV4::Attr_Accessor : QV4::Attr_Data);
runtimeClasses[i] = klass;
}