Skip to content

GC not worked #35

Description

@satoren

I'm writing benchmark. but I encountered a strange crash
this code using over 2GB memory and killed by OOM killer.

const char* lua_code =
    "local times = 5000000 \n"
    "obj = object_function()\n"
    "obj:set(3)\n"
    "if(obj:get() ~= 3)then\n"
    "  error('error')\n"
    "end\n"
    "for i=1,times do\n"
    "  obj = object_function()\n"
    "  object_compare(obj)\n"
    "end\n";
    Lua lua;
    LuaTable global = lua.GetGlobalEnvironment();
    auto object_f = lua.CreateFunction<LuaUserdata<TestClass>()>([&] {
        auto retobj = lua.CreateUserdata<TestClass>(new TestClass(object_function()));
        retobj.Bind("set", &TestClass::set);
        retobj.Bind("get", &TestClass::get);
        return retobj; });
    global.Set("object_function", object_f);

    auto object_compare_f = lua.CreateFunction<bool(LuaUserdata<TestClass>)>([](LuaUserdata<TestClass> userdata)
    {
        return object_compare(*userdata.GetPointer());
    });
    global.Set("object_compare", object_compare_f);
    lua.RunScript(lua_code);

full souce code
https://github.com/satoren/lua_binding_benchmark/blob/24a243fc396c4025db4e3623b9e93717f148e3b8/benchmark/return_class_object.hpp
https://github.com/satoren/lua_binding_benchmark/blob/24a243fc396c4025db4e3623b9e93717f148e3b8/test/luacppinterface.cpp

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions