How to properly clean a Global declared widget?

Hi,
Because I need to declare a widget.newTableView dynamically (the names of the list views depend on a data file holding the names) I use something like:
_G[“list” … categories[i]] = widget.newTableView( listOptions )

Where the categories[] table holds the names read from the data file.
It all works fine, but I want to make sure that when I want to remove the TableView I do it correctly so no memory is leaked.
This is what I do, assuming that the removeSelf() takes care of the items within the widget:

_G[“list” … categories[i]]:removeSelf()

or should I do something like:

for j=#_G[“list” … categories[i]], 1, -1 do
_G[“list” … categories[i]][j] = nil
end
_G[“list” … categories[i]] = nil
Thanks!!
[import]uid: 123200 topic_id: 21455 reply_id: 321455[/import]

You should be fine as you’re doing it although I’d tend to lean towards the second option as it’s a better habit to get into long term.

Just my 2 cents.

Peach :slight_smile: [import]uid: 52491 topic_id: 21455 reply_id: 85140[/import]