My game logic is written in JavaScript of QML, and drawing image api is realized in C++:
Q_INVOKABLE void drawImage(ColorImage* img,qreal x,qreal y);
The strange problem is if I create a big JS object:
var __gRes__ = {};
for(var i =0;i<100;i++){
var tmp= {};
for(var j=0;j<400;j++){
tmp[j] = function(){};
}
__gRes__[i] = tmp;
}
__gRes__={};
The phenomenon is my game lag periodically,even __gRes is reset to ‘{}’ in the end, as above.
I profiled and found that: every lag is caused by garbage collection.
But my big object is created only for one time. The periodical lag can not be explained.
I do not know the garbage collect mechanism of QML. My Qt version is 5.3.
Does anyone encounter such problem or do such test?
↧