How to properly remove table listeners.

Hi all,

I have been going through my game and trying to clean things up.  I was looking for a way of finding if there were any listeners I hadn’t removed properly, and I noticed that if I dump “_G.Runtime._tableListeners” table there are a lot of “empty” tables.  Below is a simple example to illustrate what I mean.  I was wondering if someone could let me know what is going on and if this is something to worry about? I can see that the reference to the table is gone, but in my game this list of ‘empty’ tables builds up quite fast.

Thanks,

Craig

[lua]local test = {}

test.tryThis = function()

return true

end

Runtime:addEventListener( “tryThis”, test )

print_r(_G.Runtime._tableListeners)

Runtime:removeEventListener( “tryThis”, test )

print_r(_G.Runtime._tableListeners)

[/lua]

Output

[tryThis] => table: 0x7fd1264d67d0 {

                 [1] => table: 0x7fd1264d6810 {

                          [tryThis] => function: 0x7fd126481f00

                        }

               }

}

table: 0x7fd1264d67d0 {

  [tryThis] => table: 0x7fd1264d67d0 {

                 [1] => table: 0x7fd1264d6810 {

                        }

               }

}

Thanks

You’re removing things correctly. 

Rob

You’re removing things correctly. 

Rob