Complete.Org: Mailing Lists: Archives: freeciv-dev: October 1998:
[Freeciv-Dev] That memory leak
Home

[Freeciv-Dev] That memory leak

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Freeciv-dev mailing list <freeciv-dev@xxxxxxxxxxxx>
Cc: Freeciv-dev mailing list <freeciv-dev@xxxxxxxxxxxxxxxxxx>
Subject: [Freeciv-Dev] That memory leak
From: Trent Piepho <xyzzy@xxxxxxxxxxxxxxxx>
Date: Sat, 24 Oct 1998 05:26:43 -0700 (PDT)

Well, I've figure out exactly what is causing the memory leak in the client.

It's not actually a leak in fact.  As some of you may know, XLib maintains
a queue of x events received from the X server, but not yet processed by the
client.  The Xt library will processes these events when it waiting for input
from the user.  Normally this queue doesn't get that many events, maybe a
hundred or two at the most. 

However, the client will process events from the civ server _before_ getting
around to X events.  If the civ server generates lots of events really fast,
like AI players and railroads will do, the X event queue can go a long time
without getting emptied.  How big will it get?  Well, try over 20,000 events
for a small game!  With a queue this big, the client takes 5.4 MB on my
machine.  I've had the client grow to over 30MB!  That's a lot of events.  By
my measurements the client will allocate another 4k page every 50 events.

As soon as the civ server shuts up for a second, the client will start to
empty the queue.  The reason it grows and grows is because the AI will make
larger and larger turns, not because of some kind of leak.

Now, the question is how to fix this.  First of all, with 30x30 tiles it
causes 60 or 90 Xevents when a unit is moved one tile.  This is because of the
smooth unit sliding effect.  It might be possible to get rid of these events. 
Another thing to do is have the client check how big the event queue has
gotten.  If it's over a certain size, have the client process it instead of
receiving events from the server.  Or just have the client process all pending
x events before starting on civ events.  The latter would probably enhance the
perceived client responsiveness.

|Gazing up to the breeze of the heavens \ on a quest, meaning, reason  |
|came to be, how it begun \ all alone in the family of the sun         |
|curiosity teasing everyone \ on our home, third stone from the sun.   |
|Trent Piepho (xyzzy@xxxxxxxxxxxxxxxx)                   -- Metallica  |



[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] That memory leak, Trent Piepho <=