Ruby: Destructors?

前端 未结 6 1989
伪装坚强ぢ
伪装坚强ぢ 2020-11-30 04:26

I need to occasionaly create images with rmagick in a cache dir.

To then get rid of them fast, without loosing them for the view, I want to delete the image-files wh

6条回答
  •  迷失自我
    2020-11-30 04:50

    Ruby has ObjectSpace.define_finalizer to set finalizers on objects, but its use isn't exactly encouraged and it's rather limited (e.g. the finalizer can't refer to the object it is set for or else the finalizer will render the object ineligible for garbage collection).

提交回复
热议问题