Cleaning up memory in script
-
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 = nilAnything else I need to think about?
-
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.
-
Thanks.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement