Results 1 to 5 of 5

Thread: Freeing DTMs

  1. #1
    Join Date
    Jun 2014
    Location
    Oklahoma
    Posts
    336
    Mentioned
    22 Post(s)
    Quoted
    231 Post(s)

    Default Freeing DTMs

    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?

  2. #2
    Join Date
    Dec 2011
    Location
    East Coast, USA
    Posts
    4,231
    Mentioned
    112 Post(s)
    Quoted
    1869 Post(s)

    Default

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

    Code:
    freeDtm(theDtm);
    or
    Code:
    freeBitmap(theBitmap);
    is all you need.

    Here's how I free mine:

    Simba Code:
    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.
    GitLab projects | Simba 1.4 | Find me on IRC or Discord | ScapeRune scripts | Come play bot ScapeRune!

    <BenLand100> we're just in the transitional phase where society reclassifies guns as Badâ„¢ before everyone gets laser pistols

  3. #3
    Join Date
    Jun 2014
    Location
    Oklahoma
    Posts
    336
    Mentioned
    22 Post(s)
    Quoted
    231 Post(s)

    Default

    Quote Originally Posted by KeepBotting View Post
    Freeing DTMs (or BMPs or fonts or sockets or anything else) does probably exactly what you're thinking--it removes them from memory.

    Code:
    freeDtm(theDtm);
    or
    Code:
    freeBitmap(theBitmap);
    is all you need.

    Here's how I free mine:

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

  4. #4
    Join Date
    Aug 2014
    Location
    Australia
    Posts
    932
    Mentioned
    53 Post(s)
    Quoted
    495 Post(s)

    Default

    I was unsure too, thanks Keep!



    New to scripting? Procedures & Functions for Beginners
    Do you use your computer at night? Just get f.lux

  5. #5
    Join Date
    Jun 2007
    Location
    The land of the long white cloud.
    Posts
    3,702
    Mentioned
    261 Post(s)
    Quoted
    2006 Post(s)

    Default

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

    Simba Code:
    freeDTMs([dtm1, dtm2, dtm3, dtm4]);

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
  •