Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2001:
[Freeciv-Dev] Re: [Patch] New city dialog (8a)
Home

[Freeciv-Dev] Re: [Patch] New city dialog (8a)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Mike Kaufman <mkaufman@xxxxxxxxxxxxxx>
Cc: Christian Knoke <ChrisK@xxxxxxxx>, Freeciv Developers <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: [Patch] New city dialog (8a)
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 10 Sep 2001 00:43:19 +0200
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Thu, Sep 06, 2001 at 08:22:58PM +0200, Raimar Falke wrote:
> On Thu, Sep 06, 2001 at 01:14:35PM -0500, Mike Kaufman wrote:
> > On Thu, Sep 06, 2001 at 08:01:47PM +0200, Raimar Falke wrote:
> > > On Thu, Sep 06, 2001 at 07:18:37PM +0200, Christian Knoke wrote:
> > > > Am Donnerstag,  6. September 2001 15:19 schrieb Raimar Falke:
> > > > > On Thu, Sep 06, 2001 at 02:53:46PM +0200, Christian Knoke wrote:
> > > > > > Hhm. While I'm writing this and playing with the dialog, X eats up
> > > > > > all my memory:
> > > > > >
> > > > > > [...]
> > > > > >
> > > > > > Never seen this before. Just opening and switching a few cities
> > > > > > makes VSZ grow from 99616 to 104380.
> > > > >
> > > > > This is normal. The X server just caches some stuff:
> > > > >
> > > > 
> > > > Really? And ends up in swapping 60 MB to my disk?
> > > 
> > > If the these 60 MB are unused data of other processes: yes.
> > > 
> > > Another reason could be that the new dialog doesn't free all allocated
> > > X11 resources.
> > 
> 
> > this is very possible. I haven't gone through carefully to make sure
> > everthing gets freed. I guess a check would be to only have one
> > city. Open and close the dialog several times. The max memory usage
> > shouldn't change after the first open?
> 
> Yes. But I think it isn't easy to debug this. Maybe you can do a
> normal memory leak test as a preparation step?!

Take mpatrol <http://www.cbmamiga.demon.co.uk/mpatrol/>. Change
Makefiles to link against libbfd and libiberty. Change mem.h:
Index: mem.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/mem.h,v
retrieving revision 1.2
diff -u -r1.2 mem.h
--- mem.h       1999/05/01 03:57:23     1.2
+++ mem.h       2001/09/09 20:59:57
@@ -22,7 +22,7 @@
  * and freeciv-specific processing occurs if it is NULL:
  * a log message, possibly cleanup, and ending with exit(1)
  */
-
+#if 0
 #define fc_malloc(sz)      fc_real_malloc((sz), "malloc", \
                                          __LINE__, __FILE__)
 #define fc_realloc(ptr,sz) fc_real_realloc((ptr), (sz), "realloc", \
@@ -32,6 +32,12 @@

 #define mystrdup(str)      real_mystrdup((str), "strdup", \
                                         __LINE__, __FILE__)
+#else
+#define fc_malloc(sz)      malloc(sz)
+#define fc_realloc(ptr,sz) realloc((ptr), (sz))
+#define fc_calloc(n,esz)   calloc((n), (esz))
+#define mystrdup(str)      strdup(str)
+#endif

Run mpatrol like
  $ mpatrol -N --show-unfreed --leak-table -g server/civserver -r test.rc
Run mpsym over the output.

test.rc ist
------
set randseed 42       # repeat a particular game (random) sequence
set seed 42           # repeat a particular map generation sequence
set timeout -1          # run a server only autogame
set aifill 7            # fill to 7 players
set endyear 2000
hard                    # make the AI do complex things
create Caesar           # first player (with known name) created and 
                        # toggled to AI mode
start
------

top 61 unfreed memory entries in leak table:

       bytes   count  location
    --------  ------  --------
      864000       9  /tmp/hawk/work/server/maphand.c line 907
      256000       1  /tmp/hawk/work/common/map.c line 214
      238144     122  /tmp/hawk/work/server/citytools.c line 820
       64869    4378  /usr/src/bs/BUILD/glibc-2.2/string/strdup.c line 43
       42120    1053  /tmp/hawk/work/server/citytools.c line 1466
This looks like a leak to me.
       30268     329  /tmp/hawk/work/server/gotohand.c line 118
       28980     207  /tmp/hawk/work/server/unittools.c line 1625
       28106     358  /usr/src/bs/BUILD/glibc-2.2/iconv/gconv_conf.c line 299
       26288       1  /tmp/hawk/work/common/nation.c line 166
       26109     561  /usr/src/bs/BUILD/glibc-2.2/intl/dcigettext.c line 621
       20008     122  /tmp/hawk/work/common/worklist.c line 29
       18096    1131  /usr/src/bs/BUILD/glibc-2.2/misc/tsearch.c line 280
       17807     567  /usr/src/bs/BUILD/glibc-2.2/iconv/gconv_conf.c line 150
       15392       2  /tmp/hawk/work/common/hash.c line 293
       12908      62  /tmp/hawk/work/server/ruleset.c line 2016
       11016       9  /tmp/hawk/work/server/maphand.c line 915
       10428       5  /tmp/hawk/work/common/government.c line 261
        8228      68  /tmp/hawk/work/server/ruleset.c line 1030
        7308     609  /tmp/hawk/work/common/genlist.c line 133
        4000      80  /tmp/hawk/work/server/gotohand.c line 203
        4000      80  /tmp/hawk/work/server/gotohand.c line 202
        4000      80  /tmp/hawk/work/server/gotohand.c line 201
        4000      80  /tmp/hawk/work/server/gotohand.c line 200
        3044       1  /tmp/hawk/work/server/ruleset.c line 2030
        2988     249  /tmp/hawk/work/common/genlist.c line 122
        2048       1  /usr/src/bs/BUILD/glibc-2.2/intl/localealias.c line 348
        1800      45  /tmp/hawk/work/server/maphand.c line 1029
        1752       1  /tmp/hawk/work/server/ruleset.c line 1428
        1620      12  /usr/src/bs/BUILD/glibc-2.2/locale/loadlocale.c line 196
         869      26  /usr/src/bs/BUILD/glibc-2.2/intl/l10nflist.c line 222
         860       1  /tmp/hawk/work/server/ruleset.c line 2060
         800       1  /tmp/hawk/work/ai/aiunit.c line 1901
         800       1  /usr/src/bs/BUILD/glibc-2.2/intl/localealias.c line 404
         780      26  /usr/src/bs/BUILD/glibc-2.2/intl/l10nflist.c line 308
         468      45  /tmp/hawk/work/common/unittype.c line 471
         416       1  /usr/src/bs/BUILD/glibc-2.2/elf/dl-object.c line 40
         372      68  /tmp/hawk/work/server/ruleset.c line 993
         292      68  /tmp/hawk/work/server/ruleset.c line 931
         276      68  /tmp/hawk/work/server/ruleset.c line 948
         276      68  /tmp/hawk/work/server/ruleset.c line 975
         244       1  /tmp/hawk/work/server/srv_main.c line 1850
         244       1  /tmp/hawk/work/server/srv_main.c line 1849
         160       5  /tmp/hawk/work/common/timing.c line 182
         132       1  /tmp/hawk/work/server/ruleset.c line 1610
         112       2  /usr/src/bs/BUILD/glibc-2.2/iconv/gconv_db.c line 215
          80       1  /usr/src/bs/BUILD/glibc-2.2/elf/dl-version.c line 286
          76       2  /usr/src/bs/BUILD/glibc-2.2/iconv/gconv_db.c line 138
          72      12  /usr/src/bs/BUILD/glibc-2.2/string/strndup.c line 46
          56       2  /tmp/hawk/work/common/hash.c line 285
          52       1  /usr/src/bs/BUILD/glibc-2.2/intl/loadmsgcat.c line 217
          49       1  /tmp/hawk/work/common/astring.c line 79
          40       1  /usr/src/bs/BUILD/glibc-2.2/elf/dl-object.c line 41
          32       1  /usr/src/bs/BUILD/glibc-2.2/iconv/gconv_conf.c line 461
          28       1  /usr/src/bs/BUILD/glibc-2.2/elf/dl-deps.c line 471
          28       1  /usr/src/bs/BUILD/glibc-2.2/elf/dl-object.c line 93
          28       1  /usr/src/bs/BUILD/glibc-2.2/elf/dl-load.c line 158
          24       1  /usr/src/bs/BUILD/glibc-2.2/iconv/gconv_dl.c line 86
          20       1  /usr/src/bs/BUILD/glibc-2.2/intl/bindtextdom.c line 236
          16       1  /tmp/hawk/work/common/shared.c line 656
           6       1  /usr/src/bs/BUILD/glibc-2.2/locale/setlocale.c line 164
           3       1  /tmp/hawk/work/common/shared.c line 761
     1763038   10635  total

The savegame and the full mpatrol output (4.5MB) is available.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "The two rules for success in life are:
  1) Never tell them everything you know."


[Prev in Thread] Current Thread [Next in Thread]