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?
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With