QSA-interest Archive, November 2006
RE: qsa memory increasing continueously
Message 1 in thread
@Gunnar, any news on this?
@postbeerliu:
Try declaring all variables x,y, sum and especially the loop variable i as
global script variables.
Now for each iteration a new variable is allocated in memory, and the
garbage collector does not pick this up properly (it should).
Regards,
Antoine
-----Original Message-----
From: postbeerliu [mailto:postbeerliu@xxxxxxx]
Sent: Friday, October 13, 2006 10:19
To: qsa-interest@xxxxxxxxxxxxx
Subject: qsa memory increasing continueously
I have write a small program based on the exampel scriptbutton to test the
qsa. in the script button's processing rountine, i continued call the
intercepter some times, thus 1000 times, 2000, 4000, 8000, I seen the memory
use is continuously increaseing,when the times up to 15,000.
the program crashed. In the script i let it do a multiply test just like
Script list below,Also the button action code list after it . Why the memory
usage is increasing continueously ? Is there any bugs in my program ?
Script:
var x = parseInt(Application.edit.text);
if ( isNaN( x ) )
{debug( "x is not a number" );}
else
{
var y = multiplyTest( x )
Application.lcd.value = y;
Application.labelResult.text = y.toString() ;
}
function multiplyTest(n) {
var sum = 1;
for ( i = 1; i <= n; i++ ) {
sum *= i;
}
return sum;
}
void ScriptButton::executeScript()
{
QTime timerMeasure ;
QString strTime;
int intCallTimes = 2000;
bool ok;
intCallTimes = Singleton::Instance
()->getHolder()->text().toInt(&ok, 10);
intCallTimes = qRound( intCallTimes );
if (( !ok )||(intCallTimes <= 0)){
QMessageBox::information( 0, "Input Error ",
"Key in numbers again!",
QMessageBox::Ok );
return;
}
if ( !code.isEmpty() ){
timerMeasure.restart();
for( int i = 0; i<intCallTimes; i++ ){
project->interpreter()->evaluate( code );
project->interpreter()->clear();
//Clear ?
}
}
strTime = "Time span is : " +
QString::number(timerMeasure.elapsed()) + "ms";
QMessageBox::information( 0, "Span",
strTime,
QMessageBox::Ok );
To unsubscribe - send "unsubscribe" in the subject to
qsa-interest-request@xxxxxxxxxxxxx
To unsubscribe - send "unsubscribe" in the subject to qsa-interest-request@xxxxxxxxxxxxx
Message 2 in thread
Antoine Megens wrote:
> @Gunnar, any news on this?
>
> @postbeerliu:
> Try declaring all variables x,y, sum and especially the loop variable i as
> global script variables.
> Now for each iteration a new variable is allocated in memory, and the
> garbage collector does not pick this up properly (it should).
>
> Regards,
> Antoine
Hi Antoine,
Its scheduled to be fixed for the next patch release of QSA. I don't
have a date for this release yet, though.
best regards,
Gunnar
To unsubscribe - send "unsubscribe" in the subject to qsa-interest-request@xxxxxxxxxxxxx