LUBE issue
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
LUBE issue
I've been using LUBE to program a network game for a couple weeks now, and recently I've noticed that the server I'm using gradually slows down over time. This is starting to get really annoying, and sometimes completely unplayable. Is there anything I can do about this, or is it just an issue with the library?
- Attachments
-
- Server.love
- (20.03 KiB) Downloaded 84 times
-
- Client.love
- (1.1 MiB) Downloaded 102 times
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: LUBE issue
This looks suspect:
Try commenting out the last line in the function. You'll get no backlog, but hopefully it won't slow down any more either.
What I would do:
Your string variable Lines kept on growing, and when you do "a = a .. b", Lua makes a new string object every time, and that gets more and more expensive when your string grows. My proposed solution uses a table, because it is easier to remove the lines you can no longer see and can thus be safely removed.
Code: Select all
function addline(text)
LineNumber = LineNumber + 1
Lines = Lines .. '\n' .. text
end
What I would do:
- Replace Lines = '' by Lines = {}
- Change addline to
Code: Select all
function addline(text) if #Lines > 100 then -- something like that table.remove(Lines, 1) else LineNumber = LineNumber + 1 end Lines[#Lines+1] = text end
- Change the drawing code to: (you might want to experiment with that)
Code: Select all
for i, line in ipairs(Lines) do love.graphics.print(line, 0, 780 + (i - LineNumber) * 14) end
Your string variable Lines kept on growing, and when you do "a = a .. b", Lua makes a new string object every time, and that gets more and more expensive when your string grows. My proposed solution uses a table, because it is easier to remove the lines you can no longer see and can thus be safely removed.
Help us help you: attach a .love.
Re: LUBE issue
Thanks for the help! I can sleep easy now knowing that the library I chose is efficient enough for my purposes.
Who is online
Users browsing this forum: No registered users and 2 guests