Immediate GC after reference clearing is not guaranteed or likely. For your test, try waiting a few seconds and/or “forcing” a GC by allocating and deallocating a bunch of memory.
This would free memory inside the reference table itself. Setting the entire variable to nil clears the handle to the variable which enables garbage collection to clean up the entire table, not just what’s inside it.
Though I will note, iirc, table.clear does not deallocate slot memory in the table. It will only remove filled slots and potentially mark the data for those for GC. For example, calling it on a table with 10 things in it will cause the table to appear empty but in memory the table will still have whatever bytes size it was.
That’s just “lucky”. There is no guarantee when the garbage collector will run and cleanup memory. You can’t do one test and assume the same behavior will happen each time, even if it was somewhat consistent.