# delete\_at – does it actually remove from RAM

**URL:** <https://metaruby.com/t/delete-at-does-it-actually-remove-from-ram/487>\
**Category:** Ruby Questions\
**Created:** [April 17, 2016, 11:40pm UTC](https://metaruby.com/t/delete-at-does-it-actually-remove-from-ram/487 "2016-04-17T23:40:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheLuigi](https://metaruby.com/letter_avatar_proxy/v4/letter/t/e68b1a/32.png) [@TheLuigi](https://metaruby.com/u/TheLuigi)\
**Post date:** [April 17, 2016, 11:40pm UTC](https://metaruby.com/t/delete-at-does-it-actually-remove-from-ram/487/1 "2016-04-17T23:40:29Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![kofno](https://metaruby.com/user_avatar/metaruby.com/kofno/32/159_2.png) [@kofno](https://metaruby.com/u/kofno)\
**Post date:** [April 18, 2016, 1:17am UTC](https://metaruby.com/t/delete-at-does-it-actually-remove-from-ram/487/2 "2016-04-18T01:17:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Ohm](https://metaruby.com/user_avatar/metaruby.com/ohm/32/828_2.png) [@Ohm](https://metaruby.com/u/Ohm)\
**Post date:** [April 18, 2016, 10:22am UTC](https://metaruby.com/t/delete-at-does-it-actually-remove-from-ram/487/3 "2016-04-18T10:22:42Z")

</div>

It is unfortunately not possible to mark an object as being ready for garbage collection in MRI.

However, as @kofno says, you can start the garbage collector with `GC.start`. You can also get stats about the garbage collector with `GC.stats`.

---

<div class="post-metadata">

**Author:** ![TheLuigi](https://metaruby.com/letter_avatar_proxy/v4/letter/t/e68b1a/32.png) [@TheLuigi](https://metaruby.com/u/TheLuigi)\
**Post date:** [April 18, 2016, 11:46pm UTC](https://metaruby.com/t/delete-at-does-it-actually-remove-from-ram/487/4 "2016-04-18T23:46:19Z")

</div>

Okay, thanks for the information — I think I know how I could make a little game that works how I’d like. 🙂
