Linux Memory leak when using Vulkan

deadfry42

Terrarian
Steam or GOG
Steam
Single Player/Multiplayer
Multi
Operating System
Linux Other
Terraria Version
1.4.4.9
Controls Used
Keyboard/Mouse
When using the Vulkan rendering engine with "/gldevice:Vulkan" in the command line arguments in steam, Terraria tends to slowly increase in memory usage over time, which obviously isn't great.

My system is an Arch Linux system on Wayland. I use an NVidia 2060 Super and have the latest 555.42.02 beta drivers. I doubt it is the drivers, however. I have 16GiB of ram.

After roughly 20 minutes of gameplay on Vulkan, Terraria uses around 5GiB of my ram and increases the longer I play. I noticed this was an issue because my PC had to use my swap memory as Terraria was using 14GiB of memory, however on OpenGL/no command line arguments, Terraria stays around 1.3GiB-1.5GiB.

This might be an issue with SDL2 upstream, but I want to report it here just in case it is an issue with Terraria itself and not SDL2. I've used SDL2 before and I haven't had any memory leaks when using Vulkan.

Please let me know if you need any more information, and thank you for reading.
 
Last edited:
Hello @deadfry42, sorry to hear you're having issues.

This memory leak appears to be a FNA issue. While unfortunately we won't be able to update the FNA libraries Terraria uses until 1.4.5 releases proper, the FNA team has released an updated library that may fix the issue you're having - no guarantees, unfortunately. :(

The library you'll want to replace is libFNA3D.so.0, which you can get from this download link. Unfortunately I'm not sure if you need the lib64 or libaarch64 version - I'm not familiar with the Linux OSes. Just manually replacing the library in Terraria's installation directory should do it, no other steps required.

Let me know if this solves the memory leak for you. If not, I'll let you know if the FNA team comes up with a (potential) fix. :)
 
Hello @deadfry42, sorry to hear you're having issues.

This memory leak appears to be a FNA issue. While unfortunately we won't be able to update the FNA libraries Terraria uses until 1.4.5 releases proper, the FNA team has released an updated library that may fix the issue you're having - no guarantees, unfortunately. :(

The library you'll want to replace is libFNA3D.so.0, which you can get from this download link. Unfortunately I'm not sure if you need the lib64 or libaarch64 version - I'm not familiar with the Linux OSes. Just manually replacing the library in Terraria's installation directory should do it, no other steps required.

Let me know if this solves the memory leak for you. If not, I'll let you know if the FNA team comes up with a (potential) fix. :)
Hi, thank you for replying!

I've replaced the libraries and all of it's dependencies, and unfortunately it still is an issue.
It does however fix another issue with rendering the Shadowflame Hades dye, which is pretty neat.
Old:
1716938757413.png

New:
1716938462049.png


Apart from that, no other immediately noticeable changes.

Also, the lib64 and libaarch64 versions refer to the system's architecture, that being x86_64 or ARM. This doesn't relate to Linux in any way. For me, because i use an x86_64 system, I used the lib64 version.

Thanks for letting me know!

EDIT: The memory leak issue WAS solved, Vulkan just uses more ram than OpenGL, which lead me to thinking that it still was an issue.

Hopefully the FNA libs get updated for 1.4.5!
 
Last edited:
Sorry to bump but I thought it would be good to mention that this is also a problem on macOS

1733761032137.png

Fixing this is a similar process to how it is on Linux, but you instead use the .dylib files in the osx directory inside of the archive Kazzymodus linked earlier
1733764444997.png

Memory usage is normal and stable again

1733761103434.png


I thought this might've been useful to point out. I really hope these performance issues are fixed in 1.4.5, it's getting pretty annoying and quite disappointing to see other OSes not getting much attention
 
Hi, could you provide new link for the FNA libs, the old link doesn’t work anymore, thank you
 

Attachments

  • IMG_2988.png
    IMG_2988.png
    147.1 KB · Views: 62

Attachments

Attachments

  • IMG_3034.jpeg
    IMG_3034.jpeg
    123.3 KB · Views: 69
Last edited:

Attachments

Last edited:
Hi thank you for reply , but libFNA3D.0.dylib that you provide crashed my game when launch, thank you
Have you replaced only libFNA3D.0.dylib or the other libraries in that folder as well? It's possible the new library is incompatible with the old ones.
 
Hi, I replaced the original libraries with the ones you provided (see the picture below). The game still crashes, but it only crashes when I replace libFNA3D.0.dylib with the new version you sent.

The other libraries that you provided me—libFAudio.0.dylib, libSDL3.0.dylib, and libtheorafile.dylib—work fine.

Thank you
1746667994966.png
 
Last edited:
Hi, I replaced the original libraries with the ones you provided (see the picture below). The game still crashes, but it only crashes when I replace libFNA3D.0.dylib with the new version you sent.

The other libraries that you provided me—libFAudio.0.dylib, libSDL3.0.dylib, and libtheorafile.dylib—work fine.

Thank you
View attachment 500692
In that case it's possible that the version of FNA that Terraria currently uses is not compatible with those new libraries. Unfortunately I won't be able to provide an intermediate fix for this, you would have to wait until our next update. I apologise for the inconvenience. :(
 
In that case it's possible that the version of FNA that Terraria currently uses is not compatible with those new libraries. Unfortunately I won't be able to provide an intermediate fix for this, you would have to wait until our next update. I apologise for the inconvenience. :(
Thank you for replying, I"ll wait for future update
 
I am waiting for this fix so badly... can't stand 34 gigs of ram usage in just 1,5 hours on m1 macbook
 
I am waiting for this fix so badly... can't stand 34 gigs of ram usage in just 1,5 hours on m1 macbook
HOW I leave my mac open on terraria for copious amounts of time and i never use that much memory
 
HOW I leave my mac open on terraria for copious amounts of time and i never use that much memory
It's Vulkan bruh, started the game 25 minutes ago
1749071820618.png
 
I think you're off by an order of magnitude here.
 
Hi, I replaced the original libraries with the ones you provided (see the picture below). The game still crashes, but it only crashes when I replace libFNA3D.0.dylib with the new version you sent.

The other libraries that you provided me—libFAudio.0.dylib, libSDL3.0.dylib, and libtheorafile.dylib—work fine.

Thank you
View attachment 500692
Yeah, Terraria doesn't use SDL3, and the newer builds of FNA seem to be only SDL2 (or something along the lines of that it's been nearly a year since I touched any of this– basically newer FNA just doesn't support terraria without some changes)

I was going to decompile it and just port it to SDL3 and apple silicon myself but I don't know if I should or not since the consensus of if relogic will do that themselves is unclear. If they want any help with that I'm willing to help though

This was the original file, rename it to fnalibs.tar.bz2 and extract it with keka: https://files.catbox.moe/k8ohjb.bz2
Attached is the same file. Just rename it and extract it and do the steps I posted earlier. Can confirm that this still all works great on my M2 macbook:

1761499158427.png


HOW I leave my mac open on terraria for copious amounts of time and i never use that much memory
This is only an issue with /gldevice:Vulkan. If you use Vulkan you get a massive performance increase but it leaks memory without these patches.
 

Attachments

Back
Top Bottom