Jump to content




Memory problems when using OO?


  • You cannot reply to this topic
6 replies to this topic

#1 H4X0RZ

  • Members
  • 1,315 posts
  • LocationGermany

Posted 22 August 2015 - 01: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

#2 InDieTasten

  • Members
  • 357 posts
  • LocationGermany

Posted 22 August 2015 - 01:16 PM

without looking into your code I would highly assume it doesn't have to do with memory allocation. good luck nevertheless

#3 Anavrins

  • Members
  • 775 posts

Posted 22 August 2015 - 03:25 PM

In your GitHub repository, I can't seem to find your "Class" file, which is where the problem probably is.

#4 H4X0RZ

  • Members
  • 1,315 posts
  • LocationGermany

Posted 22 August 2015 - 03:32 PM

View PostAnavrins, on 22 August 2015 - 03:25 PM, said:

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

#5 Exerro

  • Members
  • 801 posts

Posted 22 August 2015 - 06: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.

#6 MKlegoman357

  • Members
  • 1,170 posts
  • LocationKaunas, Lithuania

Posted 22 August 2015 - 07:58 PM

View Postawsumben13, on 22 August 2015 - 06:27 PM, said:

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 by MKlegoman357, 22 August 2015 - 07:59 PM.


#7 H4X0RZ

  • Members
  • 1,315 posts
  • LocationGermany

Posted 22 August 2015 - 11:01 PM

View PostMKlegoman357, on 22 August 2015 - 07:58 PM, said:

View Postawsumben13, on 22 August 2015 - 06:27 PM, said:

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






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users