SRL Archive - SRL Development and Help

Freeing DTMs


Camel

2014-08-17 15:46:55

This might be in the wrong forum but oh well.

I use DTMs very often in my scripts and every time the script ends I get a very very long list of all the DTMs I did not free. I honestly have no idea what this means.

I looked through a few scripts and freeing them seems rather simple (1 line actually) but I don't really understand why they need to be freed or what that even means. I'm assuming it has to do with memory conservation..

Could someone explain?

KeepBotting

2014-08-17 16:22:22

Freeing DTMs (or BMPs or fonts or sockets or anything else) does probably exactly what you're thinking–it removes them from memory.

freeDtm(theDtm);

or
freeBitmap(theBitmap);
is all you need.

Here's how I free mine:

procedure stop(); //hammer time
begin
writeWarn('*** Terminating script ***');
if isLoggedIn() then
writeDebug('Logging out');
players[currentPlayer].logout();
writeDebug('Freeing DTMs');
freeDtm(barDtm);
freeDtm(necklaceDtm);
writeWarn('*** Terminated script ***');
end;

Then just addOnTerminate('stop'); when your script starts.

Camel

2014-08-17 16:41:19

From: KeepBotting
Freeing DTMs (or BMPs or fonts or sockets or anything else) does probably exactly what you're thinking–it removes them from memory.

freeDtm(theDtm);

or
freeBitmap(theBitmap);
is all you need.

Here's how I free mine:

procedure stop(); //hammer time
begin
writeWarn('*** Terminating script ***');
if isLoggedIn() then
writeDebug('Logging out');
players[currentPlayer].logout();
writeDebug('Freeing DTMs');
freeDtm(barDtm);
freeDtm(necklaceDtm);
writeWarn('*** Terminated script ***');
end;

Then just addOnTerminate('stop'); when your script starts.


Simple enough, thanks.

Incurable

2014-08-18 20:56:34

I was unsure too, thanks Keep!

The Mayor

2014-08-18 22:56:11

Or in SRL6 you can actually free all your DTMs at once. The freeDTMs takes a TIntegerArray:

freeDTMs([dtm1, dtm2, dtm3, dtm4]);