Page 1 of 1

Out of memory trying to realloc 43084800 bytes at line 1000

Posted: Wed Feb 26, 2014 5:30 pm
by LaureatinsFrancLBE
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.

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

Posted: Wed Feb 26, 2014 6:01 pm
by cazfi
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.

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

Posted: Wed Feb 26, 2014 6:43 pm
by LaureatinsFrancLBE
I have 8 GB of RAM

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

Posted: Wed Feb 26, 2014 10:29 pm
by JTN
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.

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

Posted: Thu Feb 27, 2014 6:57 pm
by louis94
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

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

Posted: Thu Feb 27, 2014 8:16 pm
by cazfi
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)