Results 1 to 7 of 7

Thread: DTM resource usage

  1. #1
    Join Date
    Nov 2011
    Posts
    1,532
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default DTM resource usage

    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?

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

  2. #2
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    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.
    I am Ggzz..
    Hackintosher

  3. #3
    Join Date
    Nov 2010
    Location
    Australia
    Posts
    1,472
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    Quote Originally Posted by nosaj.421 View Post
    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?

    Code:
    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.

  4. #4
    Join Date
    Nov 2011
    Posts
    1,532
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by KingKong View Post
    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?

  5. #5
    Join Date
    Nov 2010
    Location
    Australia
    Posts
    1,472
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    Quote Originally Posted by nosaj.421 View Post
    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.

  6. #6
    Join Date
    Nov 2011
    Posts
    1,532
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by KingKong View Post
    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.

  7. #7
    Join Date
    Jan 2008
    Location
    10° north of Hell
    Posts
    2,035
    Mentioned
    65 Post(s)
    Quoted
    164 Post(s)

    Default

    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.

    Dg's Small Procedures | IRC Quotes
    Thank Wishlah for my nice new avatar!
    Quote Originally Posted by IRC
    [22:12:05] <Dgby714> Im agnostic
    [22:12:36] <Blumblebee> :O ...you can read minds

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •