1583 posts
Location
Germany
Posted 22 August 2015 - 02:12 PM
I'm feeling kinda stupid right now. I were working on a simple
game to test my OO utility. Now it actually works, but when I run the program multiple times, it will crash with a "too long without yielding" in my
type overwrite at line 19. Also it will become slower every time I ran the script.
At first I thought it's because _G is filled with stuff, so I added code to delete every class at the beginning of the script (the end of the utility) and it actually helped, but didn't fix the problem.
Does anyone have any idea what I did wrong?
Greetings,
H4X0RZ
355 posts
Location
Germany
Posted 22 August 2015 - 02:16 PM
without looking into your code I would highly assume it doesn't have to do with memory allocation. good luck nevertheless
756 posts
Posted 22 August 2015 - 04:25 PM
In your GitHub repository, I can't seem to find your "Class" file, which is where the problem probably is.
1583 posts
Location
Germany
Posted 22 August 2015 - 04:32 PM
In your GitHub repository, I can't seem to find your "Class" file, which is where the problem probably is.
You mean this?
http://pastebin.com/zDf5pMsK
797 posts
Posted 22 August 2015 - 07:27 PM
I think your type() function might have something to do with it. Every time you run the OO utility, it seems the type function is overridden in a way that calls the old type function, so you'd get your overridden one essentially calling itself 5 times if you ran the utility 6 times.
1140 posts
Location
Kaunas, Lithuania
Posted 22 August 2015 - 08:58 PM
I think your type() function might have something to do with it. Every time you run the OO utility, it seems the type function is overridden in a way that calls the old type function, so you'd get your overridden one essentially calling itself 5 times if you ran the utility 6 times.
Or rather 63 times, to be more precise. That's because you call it two times inside your overriden function. Try something like this, and report the result:
_G["type"] = function(obj)
local typ = _type(obj)
if(typ == "table") then
if(obj._CLASS_NAME_) then
return obj._CLASS_NAME_,true
end
end
return typ
end
Edited on 22 August 2015 - 06:59 PM
1583 posts
Location
Germany
Posted 23 August 2015 - 12:01 AM
I think your type() function might have something to do with it. Every time you run the OO utility, it seems the type function is overridden in a way that calls the old type function, so you'd get your overridden one essentially calling itself 5 times if you ran the utility 6 times.
Or rather 63 times, to be more precise. That's because you call it two times inside your overriden function. Try something like this, and report the result:
_G["type"] = function(obj)
local typ = _type(obj)
if(typ == "table") then
if(obj._CLASS_NAME_) then
return obj._CLASS_NAME_,true
end
end
return typ
end
Thanks! (to everyone who posted here.)
The problem indeed was the type function. But it wasn't fixed after using what MKlegoman told me (even though it is better performance-wise). I fixed it by changing
local _type =type
to
local _type = _G.rawtype or type