View previous topic :: View next topic |
Author |
Message |
usernotfound Expert Cheater Reputation: 0
Joined: 21 Feb 2016 Posts: 115
|
Posted: Wed Feb 08, 2017 6:36 pm Post subject: How to deal with while loops/timers eating up memory? |
|
|
I never really paid attention to it before but looking at task manager I noticed how much my trainer climbs in memory usage over time, after seeing this thread: http://forum.cheatengine.org/viewtopic.php?p=5694918 , I applied Parkours solution and it helped a bit, but is it inefficient to even be using so many timers or any while loops?
|
|
Back to top |
|
|
Zanzer I post too much Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Wed Feb 08, 2017 6:51 pm Post subject: |
|
|
You'd have to post your code in order for us to see what you're doing wrong.
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 457
Joined: 09 May 2003 Posts: 25262 Location: The netherlands
|
Posted: Wed Feb 08, 2017 6:54 pm Post subject: |
|
|
Are you calling create* functions frequently ? If so, make sure you destroy() them when you don't need them anymore
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
usernotfound Expert Cheater Reputation: 0
Joined: 21 Feb 2016 Posts: 115
|
Posted: Wed Feb 08, 2017 7:22 pm Post subject: |
|
|
@DB I use the form designer to create timers since I need them while the game is running
@Zanzer it's not really a specific issue with my current code but more in general when using over a few at once, was just wondering if there's any additional methods I could apply for less mem usage/better management to avoid a leak
|
|
Back to top |
|
|
akumakuja28 Master Cheater Reputation: 16
Joined: 28 Jun 2015 Posts: 432
|
Posted: Wed Feb 08, 2017 7:45 pm Post subject: |
|
|
Whats your memory usage. Around 100 to 200 is normal(for me) when
Using timers.
_________________
|
|
Back to top |
|
|
mgr.inz.Player I post too much Reputation: 218
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Thu Feb 09, 2017 8:12 am Post subject: |
|
|
I also had such issues. I made a cheat, AA script (which in fact is embedded Lua script inside AA script)
This one:
Code: | [ENABLE]
{$Lua}
if syntaxcheck then return end
if readInteger'[POP.exe+6DB5A8]' == nil then return 'error' end
if FreezeSandAndPowerTanksTimer==nil then
FreezeSandAndPowerTanksTimer=createTimer(nil,false)
FreezeSandAndPowerTanksTimer.Interval = 50
local readInteger,writeInteger=readInteger,writeInteger
FreezeSandAndPowerTanksTimer.setOnTimer(
function (t)
local val = readInteger'[POP.exe+6DB5A8]+7C'
if val then
writeInteger('[POP.exe+6DB5A8]-4FC' , val)
writeInteger('[POP.exe+6DB5A8]' , val*2)
end
end
)
end
FreezeSandAndPowerTanksTimer.Enabled = true
{$Asm}
[DISABLE]
{$Lua}
if syntaxcheck then return end
FreezeSandAndPowerTanksTimer.Enabled = false
{$Asm} |
And memory usage was slowly climbing. Few kilobytes per 5 seconds.
So I added those as main Lua script:
Code: | collectgarbage('setstepmul',400)
collectgarbage('setpause',150) |
Glare wrote: | if there's any additional methods I could apply for less mem usage/better management to avoid a leak |
Avoid creating and destroying new objects. Try reuse already existing ones.
Also showing us your script can by handy.
_________________
|
|
Back to top |
|
|
akumakuja28 Master Cheater Reputation: 16
Joined: 28 Jun 2015 Posts: 432
|
Posted: Thu Feb 09, 2017 10:08 am Post subject: |
|
|
mgr.inz.Player wrote: |
So I added those as main Lua script:
Code: | collectgarbage('setstepmul',400)
collectgarbage('setpause',150) |
|
Does tht keep you at a reasonable memory usage?
I have used collectgarbage() on a timer before, always felt like it was overkill, or unnecessary if I was not doing anything in Lua(Normal Game Breaking).
I just call it manually now. Its like clockwork anymore, every 10 or so changes and collectgarbage() gets a run. Your method seems promising tho.
_________________
|
|
Back to top |
|
|
mgr.inz.Player I post too much Reputation: 218
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Thu Feb 09, 2017 5:16 pm Post subject: |
|
|
Default values are 200 for each:
Code: | print('previous values',collectgarbage('setstepmul'),collectgarbage('setpause'))
>previous values 200 200 |
_________________
|
|
Back to top |
|
|
|