Assume there's a single reference to an object. Therefore reference count equals 1. Assume Lua holds the object. Assume object isn't referenced anymore, so Lua calls the _gc metamethod. Assume _gc is bound to the default luaW_gc in LuaWrapper.hpp.
In LuaWrapper.hpp, in luaW_gc, 'count' is retrieved from the counts table, then the table is updated with (count - 1) and then there's a test whether (count == 0).
However, the value that is used in the test is PRIOR to the decrement, therefore the deallocator is not called.
Should add, e.g., count = count > 0 ? count-- : 0; after the line: int count = lua_tointeger(L, -1);
and change the line: lua_pushinteger(L, count-1);
PS The strange thing is that in the luawrapperexample project this is already fixed with: lua_pushinteger(L, --count);
But note that this is not safe as count could become negative.