Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2003:
[Freeciv-Dev] (PR#6192) memory leak in cm.c
Home

[Freeciv-Dev] (PR#6192) memory leak in cm.c

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#6192) memory leak in cm.c
From: "mateusz stefek" <matusik_s@xxxxx>
Date: Thu, 18 Sep 2003 11:38:08 -0700
Reply-to: rt@xxxxxxxxxxxxxx

I don't know why nobody has answered my latest report about it.
Haven't you ever noticed that civclient uses(wastes) too much memory 
when you use CMA? (masively in many cities). Last night I even saw 
100MB client.

I read carefully cm.c and IMHO the data which is freed in my patch
is useless (This isn't some kind of cache). To prove it I wrote
cm_leak_prove.diff. Try it and you'll see that writing on that data is 
harmless.

--
mateusz

Sorry if you see this letter second time. (I send it to rt@rt.freeciv.
org but something is wrong with it)
--- freeorig/common/aicore/cm.c 2003-05-13 14:26:30.000000000 +0200
+++ freeciv/common/aicore/cm.c  2003-07-26 08:25:34.000000000 +0200
@@ -1150,6 +1150,10 @@
   for (i = 0; i < MAX_FIELDS_USED + 1; i++) {
     for (j = 0; j < MAX_COMBINATIONS; j++) {
       cache3.results[i].combinations[j].is_valid = FALSE;
+      if (cache3.results[i].combinations[j].cache1) {
+        free(cache3.results[i].combinations[j].cache1);
+        cache3.results[i].combinations[j].cache1 = NULL;
+      }
     }
   }
 
--- freeorig/common/aicore/cm.c 2003-05-13 14:26:30.000000000 +0200
+++ freeciv/common/aicore/cm.c  2003-09-18 11:18:34.000000000 +0200
@@ -32,6 +32,8 @@
 
 #include "cm.h"
 
+#include "rand.h"
+
 /*
  * Terms used
  * ==========
@@ -1150,6 +1152,10 @@
   for (i = 0; i < MAX_FIELDS_USED + 1; i++) {
     for (j = 0; j < MAX_COMBINATIONS; j++) {
       cache3.results[i].combinations[j].is_valid = FALSE;
+      if (cache3.results[i].combinations[j].cache1) {
+        memset(cache3.results[i].combinations[j].cache1, myrand(256), 
+              sizeof(*cache3.results[i].combinations[j].cache1));
+      }
     }
   }
 

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#6192) memory leak in cm.c, mateusz stefek <=