Out of memory trying to realloc 43084800 bytes at line 1000

You can get help here if Freeciv doesn't start on your computer, or if you keep getting fatal errors while playing etc.
LaureatinsFrancLBE
Posts: 2
Joined: Wed Feb 26, 2014 5:27 pm

Out of memory trying to realloc 43084800 bytes at line 1000

Postby LaureatinsFrancLBE » Wed Feb 26, 2014 5:30 pm

I am French and I'll try to talk about my bug in English so that you can understand my problem.

When I try to play freeciv with "earth-1870x720-v1.0.sav", which is a great map, and I would not put that 30 players, including 29 ia, the game does not want to start and puts the following message:

"Out of memory Trying to realloc 43084800 bytes at line 1000 of .. /.. /.. /.. / Server / maphand.c"

I would like to know if you have managed to play this map, with many players ia, because at the moment I can not play this map with ten ia.

cazfi
Elite
Posts: 1710
Joined: Tue Jan 29, 2013 6:54 pm

Re: Out of memory trying to realloc 43084800 bytes at line 1

Postby cazfi » Wed Feb 26, 2014 6:01 pm

How much memory you have (free before launching freeciv)? You're trying to use enermous map x many players (each of them having their own copy of the map as they have seen it).

1870x720 = 1346400 tiles is 15362 times larger than the large earth map of 160x90 = 14400 tiles freeciv itself ships.

LaureatinsFrancLBE
Posts: 2
Joined: Wed Feb 26, 2014 5:27 pm

Re: Out of memory trying to realloc 43084800 bytes at line 1

Postby LaureatinsFrancLBE » Wed Feb 26, 2014 6:43 pm

I have 8 GB of RAM

User avatar
JTN
Elite
Posts: 462
Joined: Wed Jan 30, 2013 12:15 am

Re: Out of memory trying to realloc 43084800 bytes at line 1

Postby JTN » Wed Feb 26, 2014 10:29 pm

Data points: If I try earth-1870x720-v1.0.sav with aifill=30 in 2.4.2 on my 8GB (+ swap) machine, memory usage looks like this in pregame:

Code: Select all

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND           
 7498 jtn       20   0  396m 259m 5488 S    0  3.6   0:14.94 freeciv-server     
 7494 jtn       20   0 1228m 145m  16m S    1  2.0   0:02.48 freeciv-gtk2       

and like this once the game has (successfully) started:

Code: Select all

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND           
 7498 jtn       20   0 2269m 2.1g 5704 S    0 29.5   0:22.97 freeciv-server     
 7494 jtn       20   0 1445m 373m  16m S    0  5.2   0:09.03 freeciv-gtk2       

(I didn't try actually playing).

I also tried setting 'revealmap=start' to fully populate the player maps, to see how much more memory that ate. The server cut the client off with "Lost connection: jtn from localhost (buffer overflow)" in this case, so I couldn't see how much memory the server consumed.

louis94
Hardened
Posts: 219
Joined: Thu Apr 25, 2013 10:17 pm
Location: Belgium

Re: Out of memory trying to realloc 43084800 bytes at line 1

Postby louis94 » Thu Feb 27, 2014 6:57 pm

Hello,

I tried loading your savegame, and I got similar results for 30 players (freeciv 2.4.2 on Arch Linux 64 bits).
I experimented with other player counts and I got the following results :

Code: Select all

Players | Server memory usage (RES column) (MB)
      1 | 340
      5 | 590
     10 | 900
     15 | 1,200
     20 | 1,500
     25 | 1,800
     30 | 2,100
     35 | 2,200

From this data, the server seems to use 57MB of memory per player, plus a constant 320MB. Given the map size of 1346400 tiles, it's about 42 bytes per tile per player.
The size of the tile struct in tile.h is about 100 bytes :

Code: Select all

1 integer : 8 bytes
8 pointers : 8*8 bytes
2 bitvectors : 2*16 bytes + size of content (?)
1 Contient_id : >= 1 byte

My analysis is wrong, but *why* ?

Louis

cazfi
Elite
Posts: 1710
Joined: Tue Jan 29, 2013 6:54 pm

Re: Out of memory trying to realloc 43084800 bytes at line 1

Postby cazfi » Thu Feb 27, 2014 8:16 pm

You are looking the "real" tile data structure. Player-specific structure is smaller (not all the information is subject to Fog of War & available to players)