Pryaxis / TShock

☕️⚡️TShock provides Terraria servers with server-side characters, anti-cheat, and community management tools.
GNU General Public License v3.0
2.43k stars 382 forks source link

Memory Leak in the latest Tshock? #1453

Closed LShirohana closed 7 years ago

LShirohana commented 7 years ago

Previous iterations of Tshock left me at 1.1 -> 1.3 GB of ram usage concurrently, never any higher really.

With the most recent build, I am currently using 1.8 GB of ram and climbing. Server started at 74% RAM usage, and now it's at 91% and very slowly climbing upwards, megabyte by megabyte. Did something change? Did I put in an awkward setting?

Server started like so

mono --server --gc=sgen -O=all TerrariaServer.exe

Thanks, and sorry in advance if this is caused by my own ignorance!

LShirohana commented 7 years ago

Update.

After a little testing, doing /save or an auto-save causes 60 MB of memory (I assume the size of my world) to be consumed, and stays consumed. I did 3-5 more manual /save's and my memory usage jumped 300 MB.

There is definitely a memory leak / garbage collection issue going on. My VSwap is going up, non-stop.

LShirohana commented 7 years ago

Another little update. Starting TerrariaServer.exe from out of the directory (Which causes TShock not to load, as far as I know?) and doing save in console still causes this issue. This leads me to believe that TShock is not the issue here but Terraria itself. I am rather confused. If I am wrong and that starting TerriaServer.exe outside of the directory doesnt stop TShock from loading let me know, I assume it does because all the commands stop working when I do that.

Below are screenshots of our memory rising every /save we did.

<20:36:20> "[zook] zook": https://dl.dropboxusercontent.com/s/wdu0er1wsmmloy3/24-1495676160.png <20:36:25> "[zook] zook": https://dl.dropboxusercontent.com/s/1u6eqnjvefchp9n/24-1495676172.png <20:36:33> "[zook] zook": https://dl.dropboxusercontent.com/s/o593ctcxoby5e6t/24-1495676180.png <20:36:43> "[zook] zook": https://dl.dropboxusercontent.com/s/7h1yral5f02ywh5/24-1495676188.png <20:36:48> "[zook] zook": https://dl.dropboxusercontent.com/s/0oh90qs70wadh7t/24-1495676194.png <20:37:01> "[zook] zook": https://dl.dropboxusercontent.com/s/aqewultos8rsrkb/24-1495676206.png
hakusaro commented 7 years ago

You'd have to test it with no plugins in the ServerPlugins folder to root out if it's OTAPI or TSAPI.

LShirohana commented 7 years ago

ServerPlugins have been renamed to backupServerPlugins to stop them from loading.

<20:51:39> "Mitch": http://i.imgur.com/IeAm4tZ.png Server loaded with 1 player inside <20:51:51> "Mitch": http://i.imgur.com/9egmP2U.png 1st save <20:52:10> "Mitch": http://i.imgur.com/Hq69JA0.png 3rd save <20:52:49> "Mitch": http://i.imgur.com/3iuuMIv.png 4th save It seems to be occuring even when ServerPlugins has been renamed to prevent loading.
QuiCM commented 7 years ago

Confirmed on TSAPI without TShock. Saving adds ~10mb of RAM on a small world on Windows

EDIT: also occurs with TShock

QuiCM commented 7 years ago

Tested on vanilla on Windows (http://terraria.org/system/dedicated_servers/archives/000/000/031/original/terraria-server-1353.zip?1493153956), issue also occurs there

LShirohana commented 7 years ago

Have you checked by saving 5+ times? Does RAM increase every single time? RAM gain seems to correlate with the size of the world. Saving on the largest size increases my RAM by 40-50 MB

QuiCM commented 7 years ago

Results of further testing: On both Ubuntu and Windows, the memory is eventually freed. However it seems to take upwards of 6 saves for this to occur, and each save adds ~50mb of RAM usage on a large world. I have no idea if the free is caused by Terraria or the OS, but there's definitely a problem here. This has been forwarded to the Terraria devs

LShirohana commented 7 years ago

Thank you. I currently cannot run Terraria on my server using a Large World as I hit 2.5 GB usage (which is insane for a server....) before it can free itself, causing the server to kill itself.

This is weirder due to the fact my Windows terraria server doesnt push past 1 GB at all, that being said, I have yet to let it save.

mistzzt commented 7 years ago

Try this plugin which improves performance and memory usage https://github.com/thanatos-tshock/Tiled/releases

ivanbiljan commented 7 years ago

I don't see an issue with TShock here, is there a reason for keeping this open? cc @QuiCM

ivanbiljan commented 7 years ago

Closing as it is not related to TShock.