On Mar 1, 2007, at 5:20 PM, Sameera Poduri wrote:
> I am simulating independent robots using multiple threads in 2.0.3.
> Everything works fine for small numbers of robots but for about 35
> robots I get an error in client.c at the following malloc (line 152)
> client->read_xdrdata = (char*)malloc(PLAYERXDR_MAX_MESSAGE_SIZE);
I assume the program aborts with a failed assertion?
In that case, this is a great example of the value of assert().
malloc() must have failed, because you've run out of memory.
PLAYER_MAX_MESSAGE_SIZE is 8MB and PLAYERXDR_MAX_MESSAGE_SIZE is
32MB. Looks like each client allocates 32+32+8=72MB for read and
write buffers. Multiply that by 35 and you're asking for 2.5GB of
The right solution is to dynamically manage those buffers, instead of
allocating them up front at the largest possible size. Until we do
that, you could fix this yourself by changing client.c to allocate
much smaller buffers, perhaps 1MB and 4MB. You could run into
problems with very large messages, but for most uses this will work.