[Interest] How to prevent large qml forms from hitting javascript stack size?

Ulf Hermann ulf.hermann at qt.io
Fri Sep 15 08:46:09 CEST 2023


 > Will it still add to total object count if this is used:?

Due to the fact that we're reserving space for all objects in the 
compilation unit, the rectangle does count towards the total. Indeed the 
calculation could be improved here. We're not going to need this stack 
slot. Maybe we should allocate stack iteratively, as needed rather than 
all of it at once. However, that will have a (small) performance cost 
for simpler documents.

It might even be possible to recycle some of the stack space once we're 
"done" with an object, but I haven't looked at it in detail.

If you're going to hack around in this, maybe first measure how much 
stack space it allocates and how much it actually uses in your case. The 
place where it uses the stack space is in createInstance():

     *sharedState->allJavaScriptObjects = QV4::QObjectWrapper::wrap(v4, 
instance);
     ++sharedState->allJavaScriptObjects;

best regards,
Ulf


More information about the Interest mailing list