Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Disposing of Table

Status
Not open for further replies.
Hi
Could anyone please help me out with this?

I'm creating a linked list within an array to help me implement my pathfinding script, for the array i am using the Table class.
Within my script i need to be able to destroy an instance of the Table class that i have created so that i can start annew.

I have tried using the .dispose method, but it does not seem to work with this class, is there any other way to destroy an instance of an object?
 

ccoa

Member

Ruby uses a garbage collector, like Java. You can't explicitly dispose objects like C(++/#)(the dispose method in the RGSS classes probably does some internal cleaning up that is needed). You can mark an object as needing garbage collected by destroying all refrences to it. In this example, setting the Table object equal to a new Table or nil.

You can also ask the garbage collector to run and sweep up all objects needing disposal by calling

GC.start

But that can slow things down while it runs. It's usually better to let the Interpreter decide when to run it.
 
Thanks, problem solved! :)

You've just given me an alternate solution, because its a little ineffecient to implement a linked list within an array, when all the items are deleted i wanted to delete the list and start anew.. however i can just set it to Table.new to reset the lot... thanks!
 

ccoa

Member

No problem. :)

This topic has been resolved. If Eivien or any other users have any questions or further problems regarding this topic, please create a new thread about them.

Thank you!
 
Status
Not open for further replies.

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top