How to Fix Crashes on Linux in A Hat in Time

Here are some potential solutions for common crashes you may encounter while playing A Hat in Time on a Linux system through Steam Play. These fixes are not guaranteed to work for everyone, but they have worked for some players.

Before Following This Guide

If you’re experiencing trouble running the game, you should add

PROTON_LOG=1

to your game’s launch options. Upon running the game, a logfile called “steam-253230.log” will be generated in your home directory. This file records all the activities performed by the game/Proton during gameplay, which could be useful in identifying the root cause of any crashes that may occur outside of a Windows environment.

Be sure to take this launch option out if you’re not using it – the log file size can grow quickly while playing.

Also, keep in mind:

  • Many of the commands in this guide assume you have root/superuser access to your system

Crash when using lots of mods, or several large mods

If you are having trouble loading the game or entering a level with certain mods installed, or going over a certain amount of mods, check your logfile for a line like this:

err:virtual:try_map_free_area mmap() error cannot allocate memory, range 0xf4f60000-0x8ad0000, unix_prot 0x3

In this case, the range doesn’t matter.

If this shows up a lot in your logs, you may have a low vm.max_map_count.

What is vm.max_map_count?

Irrespective of the Linux distribution you’re using, the system parameters in Linux can be adjusted to control various system behaviors. One such parameter is vm.max_map_count, which regulates the upper limit on the number of memory map (mmap) areas that a process can have. In case a process fails to allocate enough memory map areas, it may crash.

The default value of vm.max_map_count is approximately 65530 or 65535 in most Linux distributions, which amounts to one per 128kb of system memory or roughly 8GB of memory by default. However, to ensure maximum compatibility with Windows games, the Steam Deck ships with a value of 2147483642 (or MAX_INT – 5), eliminating the possibility of running into this issue.

Setting vm.max_map_count to 262144 (32GB) might be a more reasonable value to prevent crashes due to memory map area shortage.

You can check the current value on your system by running this terminal command (example output included):

sudo sysctl vm.max_map_count
[sudo] password for root:
vm.max_map_count = 65530

Changing vm.max_map_count temporarily

Even if you want to fix it permanently, try this first.

To change the value of vm.max_map_count, run this terminal command, replacing <num> with the number you wish to use.

sudo sysctl -w vm.max_map_count=<num>

This should take effect instantly. Try running A Hat in Time again, and see if it will boot now!

If this didn’t work for you, you can either set the value back yourself or reboot the system.

Changing vm.max_map_count permanently

Have you identified a suitable value? Excellent! The next step is to configure your system to apply the new value automatically during bootup.

To achieve this, you’ll need to make changes to the /etc/sysctl.conf file. However, if you have a /etc/sysctl.d directory, it’s preferable to create a new file called /etc/sysctl.d/99-steamplay.conf instead.

In whichever file you decide, add the following line, again replacing <num> with your number of choice:

vm.max_map_count=<num>

After making the necessary changes, remember to save the file. Once saved, reboot your system, and the new value will be automatically applied.

This guide about A Hat in Time was written by Splatsune Miku. You can visit the original publication from this link. If you have any concerns about this guide, please don't hesitate to reach us here.

About the author