Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to destroy Ruby object?

Tags:

object

ruby

Suppose there is simple object like:

object = Object.new 

As I know this creates Object in memory (RAM).

Is there a way to delete this object from RAM?

like image 982
Иван Бишевац Avatar asked Oct 22 '13 16:10

Иван Бишевац


People also ask

How do you delete an active record?

Deleting a row from a particular table or a record set from a table is pretty simple, from your console all you need to do is grab the record set by its Id then delete or destroy it.

What is garbage collector Ruby?

The Ruby Garbage Collector module is an interface to Ruby's mark and sweep garbage collection mechanism. While it runs automatically in the background when needed, the GC module lets you call the GC manually whenever required and gain insights into how garbage collection cycles are running.

How do I delete a row from a table in Ruby?

To delete a row at any location, call the deleteRows method of the Cells collection. The DeleteRows method takes two parameters: Row index, the index of the row from where the rows will be deleted. Number of rows, total number of rows that need to be deleted.


1 Answers

Other than hacking the underlying C code, no. Garbage collection is managed by the runtime so you don't have to worry about it. Here is a decent reference on the algorithm in Ruby 2.0.

Once you have no more references to the object in memory, the garbage collector will go to work. You should be fine.

like image 168
Vidya Avatar answered Sep 20 '22 08:09

Vidya