Live 7 humans online 2 active servers Peak online today 16 Record 102

Fix SoF2 “Hunk_Alloc failed” and Out-of-Memory Errors

Fix the Soldier of Fortune II "Hunk_Alloc failed" error by raising com_hunkMegs, plus the sound and model memory settings and a tidy base folder.

Updated 3 min read Fixes and settings

On this page

A “Hunk_Alloc failed” error in Soldier of Fortune II means the game ran out of the memory it reserved when it started, usually on a large custom map or with many map files installed. Fix it by starting the game with more memory: add +set com_hunkMegs 128 to the end of your shortcut’s target, or put seta com_hunkMegs "128" in your config and restart the game.

Why it happens

SoF2 runs on the Quake III engine, which grabs one block of memory, called the hunk, when it starts, and loads each map, its models and textures into it. The size of that block is set by com_hunkMegs, in megabytes. The default was chosen in 2002, when 256 MB of RAM was a lot.

When a map needs more than the hunk holds, the game stops with an error such as Hunk_Alloc failed. Custom maps with big textures, and servers that ask your game to load extra files, are the usual triggers. Your PC has plenty of memory: the game just isn’t asking for enough.

The fix: give the game more memory

com_hunkMegs is only read when the game starts, so typing it in the console during a game does nothing until you restart. There are two ways to set it.

Option 1: in the shortcut (recommended)

  1. Right-click your SoF2 multiplayer shortcut and choose Properties.
  2. Find the Target box. It ends with the program’s name, for example SoF2MP.exe", or SoF2MP.1fxmaster.exe" if you use the 1fx. patch.
  3. Add the setting after the closing quote, with a space before it, so it reads like: "C:\Games\SoF2\SoF2MP.1fxmaster.exe" +set com_hunkMegs 128
  4. Click OK and start the game from that shortcut.

Option 2: in your config

Add this line to autoexec.cfg in your base folder, then quit and start the game again:

seta com_hunkMegs "128"

Other memory settings

Two smaller memory pools can run out too. They’re also read at start-up, so set them the same way:

SoF2 memory settings
CVARWhat it doesDefaultRecommended
com_hunkMegsAmount of memory in megabytes allocated for the engine hunk.56—
s_soundpoolmegsAmount of memory in megabytes reserved for the sound pool.25—
r_modelpoolmegsMemory in megabytes allocated for the model pool.10—
  • Sounds cut out or go missing in big fights or on certain maps: raise s_soundpoolmegs to 50.
  • Models disappear or fail to load on large maps: raise r_modelpoolmegs to 20.

Tidy your base folder

Every .pk3 file in your base folder is opened when the game starts. Hundreds of old map files from servers you no longer play make start-up slower and use more memory. Move map packs you don’t need into another folder, and keep only the maps the servers you play actually use. See installing SoF2 maps for where files go.

Still crashing?

  • If the game crashes at start-up, before you ever reach the menu, it’s a different problem: see fix SoF2 crashing at start-up.
  • If it crashes only when joining one particular server, that server may need a map or mod file you don’t have, or have a damaged copy of. Delete that map’s .pk3 and download it again from our maps page.
  • If you run a server and it shows the error, add +set com_hunkMegs 128 to the server’s start command too.

Frequently asked questions

What does Hunk_Alloc failed mean in SoF2?

The game ran out of the memory block it reserved at start-up, called the hunk. Raise com_hunkMegs to 128 and restart the game.

What should I set com_hunkMegs to?

128 is plenty for any SoF2 map and leaves your PC lots of memory for everything else.

Why doesn’t changing com_hunkMegs in the console work?

The game only reads it when it starts. Set it in your shortcut or config, then quit and start the game again.

Does this happen on servers too?

Yes, a server can hit the same limit with large maps. Add +set com_hunkMegs 128 to its start command.

Was this guide helpful?

Written and kept up to date by the SOF2MP.com community. Live numbers on this page come from our own tracking of every public SoF2 server. Spotted something out of date? Tell us on Discord.