In my mobile game , I use QML. The performance is not stable and I am wondering whether the reason is garbage collection.
Since I haven’t found way to know when the QML does Garbage Collection, I used such way:
I register a C++ type into QML , and create an instance in my JavaScript code. The C++ type is different in two points:
(1)In constructor, QQmlEngine::setObjectOwnership(this,QQmlEngine::JavaScriptOwnership);
(2)In destructor, emit gcSignal();
So, eveytime QML does garbage collection, the instance will be destructed, and I can receive the gcSignal().
Is this a useful way?
Is there any other way to help?
↧