I’ve been looking for ways to manually delete objects in ruby, and I’ve come across the idea of doing a = []
a[0] = Object.new
a.delete_at(0)
This deletes it from the array and allows no way of gettin to it, but I was wondering if it really deletes the object from memory?
If not, could I use the garbage collector to do so?
delete_at removes the reference from the array but the object will not be removed from memory until the garbage collector removes it. You can start a garbage collection by calling GC#start. I’m not sure what guarantees there are about any particular object being freed on any particular collection.