Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2004:
[Freeciv-Dev] Re: (PR#10636) another aisettler memory leak
Home

[Freeciv-Dev] Re: (PR#10636) another aisettler memory leak

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] Re: (PR#10636) another aisettler memory leak
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 20 Oct 2004 00:19:22 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=10636 >

Jason Short wrote:
> <URL: http://rt.freeciv.org/Ticket/Display.html?id=10636 >
> 
> This one is rather large...
> 
> ==15964== 184552 bytes in 7363 blocks are definitely lost in loss record 
> 17 of 17
> ==15964==    at 0x1B906EDD: malloc (vg_replace_malloc.c:131)
> ==15964==    by 0x804B512: fc_real_malloc (mem.c:79)
> ==15964==    by 0x804B607: fc_real_calloc (mem.c:124)
> ==15964==    by 0x811145C: create_unit_virtual (unit.c:1695)
> ==15964==    by 0x81246F4: find_best_city_placement (aisettler.c:585)
> ==15964==    by 0x80A60F4: contemplate_new_city (settlers.c:1478)
> ==15964==    by 0x811C574: ai_manage_cities (aicity.c:976)
> ==15964==    by 0x812128E: ai_do_last_activities (aihand.c:384)
> ==15964==    by 0x804FF60: end_phase (srv_main.c:579)
> ==15964==    by 0x8051B95: main_loop (srv_main.c:1570)
> ==15964==    by 0x80523EE: srv_loop (srv_main.c:1881)
> ==15964==    by 0x8051D4B: srv_main (srv_main.c:1647)
> ==15964==    by 0x804A94E: main (civserver.c:170)
> 
> I believe it can be reproduced with the current S2_0 branch and this RC 
> file (run under valgrind with --leak-check=yes).

I think this patch will fix it.  But I haven't tested it.

jason

Index: ai/aisettler.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aisettler.c,v
retrieving revision 1.7
diff -u -r1.7 aisettler.c
--- ai/aisettler.c      30 Sep 2004 12:12:52 -0000      1.7
+++ ai/aisettler.c      20 Oct 2004 07:18:38 -0000
@@ -598,5 +598,9 @@
       best->overseas = TRUE;
       best->virt_boat = (ferry->id == 0);
     }
+
+    if (ferry->id == 0) {
+      destroy_unit_virtual(ferry);
+    }
   }
 }

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] Re: (PR#10636) another aisettler memory leak, Jason Short <=