Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2001:
[Freeciv-Dev] BUG: unfreed memory in civclient (gtk)
Home

[Freeciv-Dev] BUG: unfreed memory in civclient (gtk)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Freeciv-Dev <freeciv-dev@xxxxxxxxxxx>
Cc: Thue <thue@xxxxxxx>
Subject: [Freeciv-Dev] BUG: unfreed memory in civclient (gtk)
From: Mike Kaufman <mkaufman@xxxxxxxxxxxxxx>
Date: Sat, 28 Jul 2001 19:36:50 -0500

I'm witnessing a slow 'leak' in the (gtk) client. it's pretty hard to do. 

How to reproduce:

1. start up a game with defaults. build a city. 
2. in another window, do 

% top -d 1 -p `pidof civclient` # or whatever you do to see memory allocation

3. click on city to open up the city dialog. 
4. open the worklist dialog.
5. close the city dialog with the window manager.
6. watch the memory allocation of civclient go up.
7. repeat 3-6

what I think is happening:

in citydlg.c:2535 this is getting called

  if (pdialog->worklist_shell)
    gtk_widget_destroy(pdialog->worklist_shell);

but something like this is not:

    free(pdialog->child_worklist_dialog); 

i.e. the wldlg struct isn't getting freed


patch:  I find it hard to wade through what's going on in wldlg.c, so I won't 
code it, but a quick dirty fix might be 

move the struct worklist_dialog to wldlg.h

in struct city_dialog

-       GtkWidget *worklist_shell;
+       struct worklist_dialog *worklist_dialog;

and at citydlg.c:2535

-  if (pdialog->worklist_shell)
-    gtk_widget_destroy(pdialog->worklist_shell);
+  if (pdialog->worklist_shell){
+    gtk_widget_destroy(pdialog->worklist_dialog->shell);
+    free(pdialog->worklist_dialog);
+  }

but there's got to be a muc cleaner way, and I don't know if it's worth it for 
1.12.0 since it's so hard waste a lot of memory.

-mike

PS: I haven't looked, but there could be the same problem with the other city 
dialog popups.

PPS: whatever the eventual patch, would you CC: me the patch so I'll be sure to 
apply it to civworld.


[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] BUG: unfreed memory in civclient (gtk), Mike Kaufman <=