tosfera Posted April 3, 2016 Share Posted April 3, 2016 First of all, if you're not that experienced, don't bother reading. I got quite some knowledge in the overal package since I'm a programmer for a living, no offense but most new borns might break their heads. So, after quite some hard work being put in a system of mine I managed to find out a possible leak after aggressively spamming a button. To sketch out what I'm doing; I got a table; tmpTable. This table is holding at least 12 sub tables which will be filled with... more tables. Besides those sub tables I got 12 properties in the main table, the subtables all have around 7 to 12 properties. Nothing special. Through my code, I've been using collectgarbage('count') to see what the script is doing, at a clean restart of the resource it is around 400-420. Counting up to max 530. After around 30-40 actions, it peaks to a good 800/850. Making your FPS drop a serious amount. I went from 100 fps to a good 45. The script is drawing something depending on the location of an earlier created element. So lets say we got an element created on the screen at 0.3 and 0.5. The next element has an offset of 0.05 depending on the 0.3. so it'll be drawn at 0.35. Once the action stops, it'll clear all the data, the entire table and everything there is. Yet there is still something going wrong and I would love to know what I can do to test where it is going wrong. Things I've tried so far; clean the data every action the user does, doesn't really work. Log the results of the user to see how much memory the user uses ( peaks to 800/850 after 80 actions. ) Not move the element, so no action taken if it's being drawn ( This is a success, the fps won't drop if it's not moving ) keep the element moving at all times ( RIP fps after 80 times... ) log the sizes of the tables after clearing them all ( they're all empty.. ) I'm kinda mind blown about the usage of the memory which happens after 80 movements. ( element moves whenever I click somewhere, so after clicking 80 times it just gets messed up BADLY. ). Link to comment
Walid Posted April 3, 2016 Share Posted April 3, 2016 You can use the Web interface to view the Lua Timing on clients (check Incl Clients at the top) Enter d into the options box, and you can see which functions are using most CPU. Link to comment
tosfera Posted April 3, 2016 Author Share Posted April 3, 2016 You can use the Web interface to view the Lua Timing on clients (check Incl Clients at the top)Enter d into the options box, and you can see which functions are using most CPU. I'll give that a try Link to comment
Moderators IIYAMA Posted April 3, 2016 Moderators Share Posted April 3, 2016 - You said maximal count is 530, so it shouldn't reach 800/850? - In how many tables are the same tables stored? (this most of the time leads to a memory leak) - How do you delete and add data? - Are there MTA elements involved or are you talking about lua objects? (GUI?) If so, try the same system without MTA elements.(fake it) - Are you using functions like: https://wiki.multitheftauto.com/wiki/GetNetworkStats ? Those have their own buffers. Link to comment
tosfera Posted April 3, 2016 Author Share Posted April 3, 2016 - In how many tables are the same tables stored? (this most of the time leads to a memory leak) I got a setup which has around.. 1 global table, 12 sub tables. even if the subtables are empty, it fucks up. Most likely the tables will be filled with 5 or 6 tables which only hold properties. How do you delete and add data? first thing I'm doing is setting every subtable to nil, after that I'm clearing the entire table saying: Are there MTA elements involved or are you talking about lua objects? (GUI?) If so, try the same system without MTA elements.(fake it) Impossible, it's a GUI element which serves as a placeholder, offsets are depending on that. Moving this element would move the rest. - Are you using functions like: https://wiki.multitheftauto.com/wiki/GetNetworkStats ? Those have their own buffers. just the simple onClientRender with dxDrawText, dxDrawRectangle, and dxDrawImage. edit; Problem found, I had a really ugly handler over here: addEventHandler ( "onClientGUIMove", getRootElement(), function() isDragging = true; end ); Link to comment
Walid Posted April 3, 2016 Share Posted April 3, 2016 Try this addEventHandler ( "onClientGUIMove", getRootElement(), function() if not isDragging then isDragging = true; end end ); The important thing I mentioned in my first post is putting d into the 'Options' box. This will show which file/line number/function is using the most CPU. Link to comment
Moderators IIYAMA Posted April 3, 2016 Moderators Share Posted April 3, 2016 Ok, Well lets take a look the raw data of the system: - Which type op loops are you using? - How many times does the loop gets executed? (and is this the same as the amount of items) - How many times does: loop * loop * loop be executed? (main and sub loops) - What is the execution time of the entire code? (even if the table empty) - Does the memory drop when the loops aren't operating? If that is all correct, I need some time myself to think about it. Link to comment
tosfera Posted April 3, 2016 Author Share Posted April 3, 2016 Try this addEventHandler ( "onClientGUIMove", getRootElement(), function() if not isDragging then isDragging = true; end end ); The important thing I mentioned in my first post is putting d into the 'Options' box. This will show which file/line number/function is using the most CPU. Actually removed the entire thing, we still have a massive if-statement there. onClientGUIMove is being seriously SPAMMED. Just removed the handler once it has been detected as a move, turned it as isDragging and removed the handler once the button goes up again, so it's isDragging = false. Works perfectly. Link to comment
Moderators IIYAMA Posted April 3, 2016 Moderators Share Posted April 3, 2016 Heh? Does the event 'onClientGUIMove' gets triggered when the gui isn't moving? Link to comment
tosfera Posted April 4, 2016 Author Share Posted April 4, 2016 Nope, but whenever I was clicking, I added the new eventhandler. Which resulted into 80 handlers after a while, 80 handlers on every pixel that gets moved around by the script is pretty... stupid. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now