sol2
sol2 copied to clipboard
the example may be memory leak?
I read the https://sol2.readthedocs.io/en/latest/tutorial/cxx-in-lua.html and try it; I set the player some memory and create a lot of players in my scripts player.h:
struct player {
public:
int bullets;
int speed;
int memery[100000];
script:
for i = 2, 100000000 do
p1 = player.new()
end
p1 = nil
my task manager show that the memory increase gradually
I change the regesiter code
sol::constructors<player(), player(int), player(int, int)>());
to
"new", sol::factories(
create
)
create is defined this:
std::shared_ptr<player> create() {
return std::make_shared<player>();
}