SRL Archive - OSR Help

What increases ram and cpu usage?


CephaXz

2012-06-10 06:00:55

Have been scripting for a while now. I'd like to minimize the script ram and cpu usage as low as it can be. But I'm not sure what in a script that would cause them to increase, other than dtm or bitmap.

I have been starting and freeing my dtm with this method

begin
SetupLogin;
AddOnTerminate('FreeAllDTM');
AddOnTerminate('TakePhoto');
StartAllDTM;

repeat
MainLoop;
until not LoggedIn;
end.
It uses around 500b-550mb ram usage. So I thought only start when using them and free them after used would be more efficient. I started the dtm only in procedure that use it and free them at the end of the procedure. I see results, using only 400mb++, which is better than my normal method. But after few hours, its using 700mb+ :duh:

So I'd like to have some advices or suggestions. What would increase the resource usage in a script? And how can I reduce them?
I used 7 DTMs in total
SPS and ODTM walking, radialwalking as backup
Removed painting smart
TPA
Only one symbol finding
Others are just srl functions, and 1.3k lines script

litoris

2012-06-10 06:10:40

Every single function or procedure you use increases CPU usage, things like color finding for example.
The memory issue is probably due to Runescape, SMART is going to appear separately from Simba in the task manager after the next update so you can see how much memory your script uses then.

Le Jingle

2012-06-10 06:15:06

You are also likely to have not freed a/an DTM(s) properly; as a symptom of not freeing them correctly will increase your ram over time, as you stated in the OP. AddOnTerminate simply free's the DTM's you have selected to free when you press the stop button or hit f2 in the running simba script. My suggestion would be to overview your DTM's and possibly set/free them more/right. If you need help, I could try assisting too.

Cheers

CephaXz

2012-06-10 06:40:46

From: Le Jingle
You are also likely to have not freed a/an DTM(s) properly; as a symptom of not freeing them correctly will increase your ram over time, as you stated in the OP. AddOnTerminate simply free's the DTM's you have selected to free when you press the stop button or hit f2 in the running simba script. My suggestion would be to overview your DTM's and possibly set/free them more/right. If you need help, I could try assisting too.

Cheers


I thought starting all dtm at the start of the script and freeing them when script is terminated is the best way since you don't need to load and free them everytime you need to use that function/procedure.

So you're recommending me to load and free inside a procedure/function instead of loading all at once and free after terminated?

litoris

2012-06-10 06:57:14

From: CephaXz
I thought starting all dtm at the start of the script and freeing them when script is terminated is the best way since you don't need to load and free them everytime you need to use that function/procedure.

So you're recommending me to load and free inside a procedure/function instead of loading all at once and free after terminated?


When a script stops (ie terminated), all the DTMs and bitmaps are released anyway. Loading them once should be enough. The only way to screw up memory is to use DTMFromString(**) every time you use a DTM. At least that's what I was told when asked about it.

Rich

2012-06-10 13:52:05

From: litoris
When a script stops (ie terminated), all the DTMs and bitmaps are released anyway. Loading them once should be enough. The only way to screw up memory is to use DTMFromString(**) every time you use a DTM. At least that's what I was told when asked about it.
They still need to be freed, otherwise they just be sitting there unnecessarily hogging your memory.

Hazzah

2012-06-10 14:13:27

Would the proper use of DTMs be to setDTM := DTMfromstring=(…) in a procedure and then free it at the end of that procedure? Like in the script I am using I use the same DTM in two different procedure, so I can understand using that one as a Global but other I use are only used for a single procedure, so would it be better to load and free those DTMs within that procedure?

Procedure SetDTM; //Sets all the DTMS needed to run the script.
Begin

SummoningPotionDTM := DTMFromString('mWAAAAHicY2FgYHBigmBXIPYEYn1GBgYrILaE4vz8Ega5a3cZZC/dBKpmYkgBkuxImBENgwAAgewHaA==');
ROWDTM:= DTMFromString('mrAAAAHic42BgYPjHxMDAzAzBf4DsL0D8CYi/A/EvIJ7HyMAwE4gXAfEqIF4OxAuAeDYQzwDi23vlgKYw4cT8DPgBIwEMAwClEwzS');
TABLEDTM:= DTMFromString('mrAAAAHic42BgYLjAxMBwH4gvA/FxID4MxOeA+CZUfBEjA8NqIF4DxXOAeAYUzwLiesE6oClMODEPA37ASADDAADlrQzu');
WarTortPouch := DTMFromString('mbQAAAHicY2VgYDAFYisg1gNiGyC2BuL3QPwEiD8A8RcgfgfEna4iDFfO7GDQ15BnaHcRAWN+oDg6ZsSCwQAAEz8LfQ==');
End;

Only the TABLEDTM really needs to be global so would that be better to have only that one loaded globally and load the other only when necessary?