Log in

View Full Version : DTM resource usage



Er1k
01-11-2012, 04:12 AM
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
01-11-2012, 04:14 AM
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
01-11-2012, 04:37 AM
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
01-11-2012, 05:18 AM
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
01-11-2012, 06:49 AM
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
01-11-2012, 10:24 AM
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
01-11-2012, 10:30 AM
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.