SRL Archive - Help

DTM resource usage


Er1k

2012-01-10 23:12:07

We know DTMs if not released will cause memory leaks. That's bad. I'm just thinking what about the overhead of loading DTM from string and immediately releasing it each time it's been used? Is that bad as well?


procedure something;
var dtm: integer;
begin
dtm:= DTMFromString('...');
//do whatever is needed
FreeDTM(dtm);
end;

Brandon

2012-01-10 23:14:57

I think you're supposed to release it after.. I hate to see when ppl actually load all dtm's in one procedure and then free them all in another procedure.. I free them immediately after use. I "believe" it's the right way to do it.

KingKong

2012-01-10 23:37:26

From: nosaj.421
We know DTMs if not released will cause memory leaks. That's bad. I'm just thinking what about the overhead of loading DTM from string and immediately releasing it each time it's been used? Is that bad as well?


procedure something;
var dtm: integer;
begin
dtm:= DTMFromString('...');
//do whatever is needed
FreeDTM(dtm);
end;


Thats the way its supposed to be done. Load the dtm -> use it-> if not needed again, free it. But if you're going to call load/free dtm a lot of time, then thats going to increase mem too.

Er1k

2012-01-11 00:18:59

From: KingKong
Thats the way its supposed to be done. Load the dtm -> use it-> if not needed again, free it. But if you're going to call load/free dtm a lot of time, then thats going to increase mem too.


Still is it better to increase mem than to cause memory leaks?

KingKong

2012-01-11 01:49:20

From: nosaj.421
Still is it better to increase mem than to cause memory leaks?


mem leak = mem increase. But its due to poor memory management(such as not freeing dtm's). As i said before, it depends on how many times you use the dtm in your script, and if its worth freeing after each call to finddtm.

Er1k

2012-01-11 05:24:43

From: KingKong
mem leak = mem increase. But its due to poor memory management(such as not freeing dtm's). As i said before, it depends on how many times you use the dtm in your script, and if its worth freeing after each call to finddtm.


Thanks for pointing out. Now I think I have a better idea on where to put the freeDTMs instead of putting them at the end, which really bothers me back then.

Dgby714

2012-01-11 05:30:09

It would be best for them to have a short lifespan.
Tho if your about to go into a loop that uses the DTM, Create it before the loop. Free after.