Crystal lang, is it possible to explicitly dispose (free) of instance (object) without waiting for GC? -


the title says all. maybe there's method can called def destruct; delete self;end?

it's possible, not recommended , way i'll show might change or break in future. why need this? idea of gc precisely not worrying such things.

class foo   def initialize     @x = 10   end    def finalize     puts "never called"   end end  foo = foo.new p foo # => #<foo:0x10be27fd0 @x=10> gc.free(pointer(void).new(foo.object_id)) # line frees memory p foo # => #<foo:0x10be27fd0 @x=1> 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -