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

android - net_scheduler holding wakelock -

sql - MySQL : Getting Entries from a many-to-many table -

java - Retrieving data from database using jsp (Hibernate + Spring + Maven) -