How to destroy Ruby object?

前端 未结 4 1994
有刺的猬
有刺的猬 2020-12-05 13:46

Suppose there is simple object like:

object = Object.new

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

Is there a way to delete th

4条回答
  •  臣服心动
    2020-12-05 14:34

    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.

提交回复
热议问题