I know this has been answered however the answer is actually a bit more complex and harder to explain, but in a tl;dr, it’ll become your second example.
Whenever you have a table, you have strong and weak references. All references by default are strong, meaning they cannot get garbage collected until specific requirements are met, and there are some primitive types, like strings, numbers, booleans, tables, etc which are strong references no matter the table strength iirc. To make a table weak, you have to give it a metatable and then use a metamethod, and if you want to learn more about that then go here.
Now, from what I can presume your “object2” is an Instance in a strong table. This means the reference to the object is always there however all though it’s deleted, the table has cached it’s values and as such still has access to them.
Values with strong references to them will never be collected, you’d need to nil those strong references beforehand in order for the value to be collected by the garbage collector upon its direct next garbage collection cycle.