• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

TFS 1.X+ Optimize RAM

Fortera Global

Intermediate OT User
Joined
Nov 20, 2015
Messages
1,180
Solutions
2
Reaction score
117
What can I do to optimize the use of RAM? Script examples that can take up too much RAM?

tfs 1.x+

thanks
 
Solution
In 2018:
Get better dedic.

Script that consume too much RAM? Scripts with memory leak.
In many cases it's better to leave small memory leak in LUA to reduce CPU usage.

Example:
Some temporary table with NPC state.
PHP:
local function creatureSayCallback(cid, type, msg)
   if not npcHandler:isFocused(cid) then
      return false
   end
   local player = Player(cid)
   if isInArray({"soft", "boots", "repair", "soft boots"}, msg) then
      npcHandler:say("Do you want to repair your worn soft boots for 10000 gold coins?", cid)
      npcHandler.topic[cid] = 1
   elseif msgcontains(msg, 'yes') and npcHandler.topic[cid] == 1 then
...
There is table 'npcHandler.topic' indexed by 'cid'. 'cid' changes every relog, so after player...
just do collectgarbage("count") / 1024 for MB
and yes, if your process is using ~4.4 gigs of memory it's your sources, not Lua
have you restarted your server and watched memory as time goes on?
generally if you have a memory leak over time you'll see it keep growing and growing

:eek: yes, she goes up gradually onmg
 
look up valgrind on google, learn how to use it to search for memory leaks in your engine

thanks bro!
I used valgrind and its generate one output but the TFS dont starts :
command: valgrind --leak-check=full -v --log-file=valgrind-out.txt ./tfs
imd3sh7.png



Output:
https://ghostbin.com/paste/gojj7

did u understand something?
 
Hey guys, the best way is the player:getGuid(), right?
because the other method player can say "bye" to npc and the function onDisappear dont will execute, I'm wrong?
 
Back
Top