I have a ring buffer that is updated through an event, as you know, the ring buffer keeps an index for where to insert the next item, when the buffer is full for the first time, the next entry will overrid the oldest entry, should I set the oldest entry to nil before overriding or just override it?
I did both and it seems that setting it to nil is more efficient.
From my primitive understanding, it seems like setting an entry to nil will notify the garbage collector to clean it up immediately, while overriding it will cause the next garbage collection cycle to look for that entry to delete it, so threre is some searching required, also when the garabge collection cycle kicks in, if there are a lot of entries, it will freeze for couple frames to get it cleaned up compared to just cleaning it up explicitely by setting the entry to nil.
Please tell me how this works?