sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Cleaning up memory in script

    Scheduled Pinned Locked Moved Developers' Forum
    3 Posts 2 Posters 867 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • PixeroP Offline
      Pixero
      last edited by

      What are the best ways of cleaning up memory at the end of a script?

      Let's say I use some temp stuff like vectors for example.
      Do I need to clean them up with something like:

      temp_vector = nil

      Anything else I need to think about?

      1 Reply Last reply Reply Quote 0
      • S Offline
        slbaumgartner
        last edited by

        The Ruby Garbage Collector runs automatically every so often and reclaims memory from all objects to which there is no remaining reference. All ordinary references are released as soon as they go out of scope. So, unless your script is holding references in persistent variables, such as globals, class, and module variables, there is usually nothing more you need to do.

        If you think you have generated a lot of dangling objects, you can explicitly initiate garbage collection via methods in the GC module. SketchUp may take a noticeable hit when you do so because everything else must be suspended while the collection takes place. So, if you are creating a lot of small objects (e.g. to assemble Strings piece by piece) it is usually better to rethink your code to pre-allocate larger objects and add data into them incrementally.

        1 Reply Last reply Reply Quote 0
        • PixeroP Offline
          Pixero
          last edited by

          Thanks.

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          • First post
            Last post
          Buy SketchPlus
          Buy SUbD
          Buy WrapR
          Buy eBook
          Buy Modelur
          Buy Vertex Tools
          Buy SketchCuisine
          Buy FormFonts

          Advertisement