How to destroy Ruby object?

前端 未结 4 1999
有刺的猬
有刺的猬 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:29

    You can't explicitly destroy object. Ruby has automatic memory management. Objects no longer referenced from anywhere are automatically collected by the garbage collector built in the interpreter.

    Good article to read on how to do allocation wisely, and a few tools you can use to fine tune.

    http://merbist.com/2010/07/29/object-allocation-why-you-should-care/

提交回复
热议问题