[Interest] QML: Considerations on an interesting design pattern that relies on JS engine's garbage collection
Fatih Uzunoğlu
fuzun54 at outlook.com
Fri Apr 11 18:05:58 CEST 2025
> However, if you create a new Component object in every
> derived type you probably haven't saved a lot of memory
Is not this because of the same long-standing issue?
```
// Base.qml
property Component component : Component {
id: baseComponent
SomeType { }
}
```
```
// Child.qml
Base {
component: Component {
id: childComponent
SomeOtherType { }
}
}
```
QML does not currently allow a way to disable creating `baseComponent`.
I read that this is not fixed because of side-effects. But `Component`
is not something that can cause side-effects (can it?).
So perhaps `Component` can be treated differently: 1) always garbage
collected (does not have parent), so when not referred, it is destroyed.
2) all `Component` properties are deferred by default (so it is not even
created in the first place). What do you think?
> What we should actually do is expose deferred properties to QML
That would be really helpful, but as far as I see it does not help with
these:
- The component is changed in derived type at any arbitrary time.
- The property has a complex binding that we want to avoid repeating in
the derived type.
My understanding is that the garbage collection approach would be fine
with both.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20250411/1d8b75d9/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4676 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20250411/1d8b75d9/attachment.bin>
More information about the Interest
mailing list