From: fadden@uts.amdahl.com (Andy McFadden)
Newsgroups: rec.games.netrek
Subject: Re: Possible Memory Leak in latest (but before rsa) client
Date: 14 Dec 92 22:08:04 GMT
Reply-To: fadden@amdahl.uts.amdahl.com (Andy McFadden)
Organization: Amdahl Corporation, Sunnyvale CA

In article <101910@netnews.upenn.edu> jkuner@be.seas.upenn.edu (John A. E. Kuner) writes:
>I've been noticing that recently, when I play netrek from an NCD terminal,
>there seems to be a memory leak bug somewhere. First, I get a 'Low on Memory -
>any attempt to open new windows will result in error' or something like that.
[...]

You need to be more specific about what the "latest client" is, unless there's
a single source of clients that I'm missing.  I think I can nail this one,
but in the future please be specific about which client it is and where you
got it from.

There was a problem in the original Hadley client that caused this (I could
go for an hour or so, but a guy downstairs with a color monitor would play
for about 1.5 minutes before he got booted).  Didn't have a problem on a
color Solbourne though.

Here's Tedd's fix; not sure if it applies to the newer clients.  It worked
for me.

-----
   I haven't had a problem either on my color sun.  The X implementation 
   must do a better job of sharing colors.  But it is a memory leak alright, 
   I forgot to call XFreeCursor.  Here's a patch:


*** input.c	Sat Aug 15 13:19:36 1992
--- ../input.c	Tue Aug 25 14:48:57 1992
***************
*** 654,660 ****
      struct obtype *gettarget();
  
  #ifdef NOWARP
!     message_off();		/* ATM */
  #endif
  
  #ifdef SHORT_PACKETS
--- 654,661 ----
      struct obtype *gettarget();
  
  #ifdef NOWARP
!     if(messageon)
!        message_off();		/* ATM */
  #endif
  
  #ifdef SHORT_PACKETS
*** x11window.c	Sat Aug 15 13:19:42 1992
--- ../x11window.c	Tue Aug 25 14:56:52 1992
***************
*** 7,13 ****
  #include <stdio.h>
  #include <X11/Xlib.h>
  #include <X11/Xutil.h>
! #ifdef TSH
  #include <X11/cursorfont.h>
  #endif
  #include <assert.h>
--- 7,13 ----
  #include <stdio.h>
  #include <X11/Xlib.h>
  #include <X11/Xutil.h>
! #ifdef TCURSORS
  #include <X11/cursorfont.h>
  #endif
  #include <assert.h>
***************
*** 158,163 ****
--- 158,166 ----
  #ifdef SHORT_PACKETS
      int  insensitive;
  #endif
+ #ifdef TCURSORS
+     Cursor	cursor;
+ #endif
  };
  
  struct stringList {
***************
*** 1372,1377 ****
--- 1375,1383 ----
  #ifdef SHORT_PACKETS
      newwin->insensitive = 0;
  #endif
+ #ifdef TCURSORS
+     newwin->cursor = NULL;
+ #endif
      return(newwin);
  }
  
***************
*** 1750,1758 ****
--- 1756,1768 ----
     XQueryColor(W_Display, W_Colormap, &f);
     XQueryColor(W_Display, W_Colormap, &b);
  
+    if(win->cursor)
+       XFreeCursor(W_Display, win->cursor);
+ 
     new = XCreateFontCursor(W_Display,  XC_tcross);
     XRecolorCursor(W_Display, new, &f, &b);
     XDefineCursor(W_Display, win->window, new);
+    win->cursor = new;
  }
  
  void W_DefineTrekCursor(window)
***************
*** 1769,1777 ****
--- 1779,1791 ----
     XQueryColor(W_Display, W_Colormap, &f);
     XQueryColor(W_Display, W_Colormap, &b);
  
+    if(win->cursor)
+       XFreeCursor(W_Display, win->cursor);
+ 
     new = XCreateFontCursor(W_Display,  XC_trek);
     XRecolorCursor(W_Display, new, &f, &b);
     XDefineCursor(W_Display, win->window, new);
+    win->cursor = new;
  }
  
  void W_DefineWarningCursor(window)
***************
*** 1788,1796 ****
--- 1802,1815 ----
     XQueryColor(W_Display, W_Colormap, &f);
     XQueryColor(W_Display, W_Colormap, &b);
  
+    if(win->cursor)
+       XFreeCursor(W_Display, win->cursor);
+ 
     new = XCreateFontCursor(W_Display,  XC_pirate);
     XRecolorCursor(W_Display, new, &f, &b);
     XDefineCursor(W_Display, win->window, new);
+ 
+    win->cursor = new;
  }
  
  void W_DefineArrowCursor(window)
***************
*** 1807,1815 ****
--- 1826,1839 ----
     XQueryColor(W_Display, W_Colormap, &f);
     XQueryColor(W_Display, W_Colormap, &b);
  
+    if(win->cursor)
+       XFreeCursor(W_Display, win->cursor);
+ 
     new = XCreateFontCursor(W_Display,  XC_left_ptr);
     XRecolorCursor(W_Display, new, &f, &b);
     XDefineCursor(W_Display, win->window, new);
+ 
+    win->cursor = new;
  }
  
  void W_DefineTextCursor(window)
***************
*** 1826,1834 ****
--- 1850,1863 ----
     XQueryColor(W_Display, W_Colormap, &f);
     XQueryColor(W_Display, W_Colormap, &b);
  
+    if(win->cursor)
+       XFreeCursor(W_Display, win->cursor);
+ 
     new = XCreateFontCursor(W_Display,  XC_xterm);
     XRecolorCursor(W_Display, new, &f, &b);
     XDefineCursor(W_Display, win->window, new);
+ 
+    win->cursor = new;
  }
  #endif 
  

-- 
fadden@uts.amdahl.com (Andy McFadden)
[ Above opinions are mine, Amdahl has nothing to do with them, etc, etc. ]
-- 
fadden@uts.amdahl.com (Andy McFadden)
[ Above opinions are mine, Amdahl has nothing to do with them, etc, etc. ]