Jump to content
Sign in to follow this  
tuk0z

[memory] Avoiding system freeze thx to dynamic swap space for Linux players

Recommended Posts

Hi guys / salut les gens

So my 8 GB Core i3 went stuck on some longer 0 A.D. games with the pyrogenesis game engine taking all of the available 9 GB RAM + swap memory. One of the rare moments where my Arch Linux OS got stuck, as carefully optimized as I try to make it (100% CPU and 99% of total RAM is available for *apps*, hello Windows :)). The setting I've applied has solved the issue so far so why not sharing with you Linux boys & girls?

Even though there might be other, atm I saw three solutions:

  1. To become good enough so no game takes me over 45 min in a row, but considering my level... oh well, better look somewhere else :}
  2. One reflex would be to increase my swap size, taxing GBs of space from my disks all the time so no thanks.
  3. Dynamically create swap space *if and when needed*
    I remembered having read something about a tool that just does that (when I worked on making older/smaller machines as efficient as possible for the desktop user/usage using FOSS). It's *systemd-swap*. 
     
Quote

systemd-swap is a script for creating hybrid swap space from zram swaps, swap files and swap partitions. It is not affiliated with the systemd project.

Bye bye system freeze since I activated it. Worst case system becomes a fair bit slower (in which case it was already too late with my previous settings using just RAM + zswap + swap), for a couple seconds then regains some responsiveness. In which case I save the game, exit and reopen/play it. Haven't tested in lobby yet. I also tried to keep playing, and man it is playable. In worst case, Pyrogenesis used 8 GB RAM + 7-8 GB swap =]:beta:

If systemd-swap is installable for your system, activating and making use of it is a matter of opening its conf file, activate the 'swapc' (dynamic swap file(s)), close and start the service. Official details here:

- Automated swap file(s) using systemd-swap (Arch wiki)
- En FRANÇAIS Optimiser la gestion de la RAM et du Swap sous Linux (dolys.fr 2018-01) 

 

  • Confused 1

Share this post


Link to post
Share on other sites

0ad shouldn't be consuming more than 2 gb for any normal gameplay. Obviously, you're experiencing some sort of massive memory leak happening there if 9 gb are being used by min 45. So yeah seems restarting 0ad is the only fix for now. :)

Share this post


Link to post
Share on other sites

Thanks; to be frank I was worrying the issue to be my $%# level at English or you having a gazillion RAM not getting the frustration to loose an epic match the moment OS memory fills up. Btw am using the official package and have not meet such issue with other software yet. « Shouldn't » yeah, but I've seen other posts mentioning memory (leaks) up to over 2GB (or the Windows© builds going wrong at 2 GB RAM). I've went over that oftenly, though, you're right, maybe in more than 45' :) but I play super slowly when learning.

Therefore sharing a system conf (dynamic swap files automatically created if needed then removed) that fixes the "memory takes" (here at least) without "downloading" more RAM he he

EDIT:

Here's the kind of load I'm dealing with (upon a 2-3 hours game tonight). Only happens here, really?
$ sudo ps_mem

 Private  +   Shared  =  RAM used    Program

  ...
 16.3 MiB +  16.8 MiB =  33.1 MiB    WebKitNetworkProcess
 22.4 MiB +  23.4 MiB =  45.8 MiB    WebKitWebProcess
 17.8 MiB +  33.8 MiB =  51.5 MiB    Xorg
 25.6 MiB +  39.5 MiB =  65.0 MiB    vimb
  7.1 GiB +   7.1 GiB =  14.2 GiB    pyrogenesis
---------------------------------
                         14.5 GiB
=================================

$ top -b -n1

top - 06:26:15 up 1 day, 11:09,  2 users,  load average: 1,22, 6,95, 6,48
Tasks: 195 total,   1 running, 194 sleeping,   0 stopped,   0 zombie
%Cpu(s):   8,5/2,1    11[                                                                                                    ]
GiB Mem : 89,0/7,7      [                                                                                                    ]
GiB Swap: 75,2/3,5      [                                                                                                    ]

    PID USER      PR  NI    VIRT    RES  %CPU  %MEM     TIME+ S COMMAND
 498003 kozaki     7   0 9228,7m   4,8g   6,2  61,6 307:11.59 S pyrogenesis

ps_mem shows some of the used memory twice in the case of pyrogenesis ('Private + Shared' memory); I've left only the top 5 running applications using the most memory.

top says that 89% of the available 7.7 GB RAM is used as well as 75% of the 3.5 GB (dynamically created) swap. Also says pyrogenesis uses 9228 MB of memory.

Edited by tuk0z
+ memory usage example
  • Like 1

Share this post


Link to post
Share on other sites

Salut @tuk0z ,

Thanks for the detailed report. We have quite a few memory leaks. Hopefully only in external libraries but I wouldn't bet on it.

Share this post


Link to post
Share on other sites

Guys please note I intended this post to report how we can improve the memory constraints with the game as it is (a23). Also not everyone plays hours long games I think.

@Angen Sure man, I'll clone && build it after a) today 'First 5min training' and b) shifting my build $PATH from tmpfs to a bigger partition. Arch has a PKG ready for the game dev version.

Share this post


Link to post
Share on other sites
1 minute ago, tuk0z said:

Arch has a PKG ready for the game dev version.

Last time I checked with an arch linux user it did weird things. But your mileage might vary.

Share this post


Link to post
Share on other sites

@Angen have done memory measurements on a few a23.1 games (while failing at compiling dev atm - thread's not for that one tho). Do you know if there's an existing thread showing memory measurements? Pyrogenesis consistently reaches 5 GB memory around 60 minutes running in this location.

EDIT: Note that the on-demand swap tip I shared in this post should address most "compiling 0 A.D. freezes system for memory issues" that I've seen here and there while reading compilation-related threads on the forum.

Edited by tuk0z
Correctly mentionning Angen

Share this post


Link to post
Share on other sites
2 hours ago, tuk0z said:

Do you know if there's an existing thread showing memory measurements? Pyrogenesis consistently reaches 5 GB memory around 60 minutes running in this location.

Not that I know of. However on windows it cannot go higher than 4GB. Can you share your match settings, maybe a replay?

2 hours ago, tuk0z said:

while failing at compiling dev atm -

How can I be of assistance?

  • Like 1

Share this post


Link to post
Share on other sites
On 12/10/2019 at 2:16 PM, Angen said:

@tuk0z would you be willing to get development version and try if you have the same problems with that?

 

5 hours ago, Stan` said:

Can you share your match settings, maybe a replay?

Done guys.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...