Closed mirchd closed 6 years ago
function CppObjectBase:Destroy()
for v in pairs(self._gc_list) do
if v.Release then
v:Release()
end
end
LinkAgainstGC[self] = nil
local _cppinstance_ = rawget(self, "_cppinstance_")
if _cppinstance_ then
if _cppinstance_.Destroy then
_cppinstance_:Destroy()
end
_setexisttable(_cppinstance_, nil)
rawset(self, "_cppinstance_", nil)
end
LevelActors[self] = nil
end
yes,this may be a bug. Add the code to the CppObjectbase 's Destroy function may help.Look forward your feedback.
it seem to be ok, thank you very much!
why it happen? the ptr of cpp ins reused by UE4?
yes,after UE4 GC,the memory in cpp will be reused.But lua didn't GC at the same time.So it's cppins->luains relationship is out of time.I will fix this bug latter.
so if i use cpp ptr as some key, it may also has some problem in ue4,
thanks
if you mark it with UPROPERTY, then don't worry about it,I won't be reused.Otherwise, you shouldn't keep uobject* ptr.
en, unreal.lua is a good job, thanks
void ASLGBuildingActor::BeginPlay() { Super::BeginPlay(); LuaCall("beginPlay", this); }
function Call(functionName, inscpp, ...) if type(inscpp) == "table" and not inscpp._hasdestroy then return inscpp[functionName](inscpp, ...) else dump(inscpp) ensure(false, "error in Call, No Exist such lua ins or ins has been released") end end
lua.log:
[Thu Mar 8 22:06:29 2018] - }
[Thu Mar 8 22:06:29 2018] - "_gc_list" = {
[Thu Mar 8 22:06:29 2018] - userdata: 0000000089E33548 = true
[Thu Mar 8 22:06:29 2018] - }
[Thu Mar 8 22:06:29 2018] - "_hasdestroy" = true
[Thu Mar 8 22:06:29 2018] - "beginPlay" = function: 00000000850A2AE8
[Thu Mar 8 22:06:29 2018] - "initNameInfo" = function: 00000000850A2AC0
[Thu Mar 8 22:06:29 2018] - "m_HasBeginPlay" = true
[Thu Mar 8 22:06:29 2018] - "m_HasEndPlay" = true
[Thu Mar 8 22:06:29 2018] - }
...al/SteelOcean/Client_4.18/LuaSource/util\logutil.lua:57: error in Call, No Exist such lua ins or ins has been released...al/SteelOcean/Client_4.18/LuaSource/util\logutil.lua:57: error in Call, No Exist such lua ins or ins has been released stack traceback: [C]: in function 'error' ...al/SteelOcean/Client_4.18/LuaSource/util\logutil.lua:57: in function 'ensure' E:/Unreal/SteelOcean/Client_4.18/LuaSource/main.lua:85: in function <E:/Unreal/SteelOcean/Client_4.18/LuaSource/main.lua:80>
the ASLGBuildingActor new and delete frequently。 please help