From:	SMTP%"RELAY-INFO-VAX@CRVAX.SRI.COM"  1-SEP-1993 08:13:47.33
To:	EVERHART
CC:	
Subj:	Leak in xautolock found

From: bdr@cbnewsg.cb.att.com (brian.d.reed)
X-Newsgroups: comp.os.vms
Subject: Leak in xautolock found
Keywords: xautolock, leak, memory
Message-ID: <CCn60M.6AG@cbfsb.cb.att.com>
Date: 31 Aug 93 20:53:09 GMT
Sender: news@cbfsb.cb.att.com
Organization: AT&T
Lines: 37
To: Info-VAX@KL.SRI.COM
X-Gateway-Source-Info: USENET

A memory leak in xautolock has been found (thanks to Kevin Oberman--
oberman@icdc.llnl.gov).  I 'ported' the code to VMS, which was essentially
just getting a WAIT3 function emulated.  The problem is that xautolock
slowly increased in size, becoming noticeable after running for an extended
period (days to weeks).  Following is the correction, and an
exuse\\\planation.  My apologies for any inconvenience.


In the WAIT3.C file, around line 60, add the line
with XFree, so that it looks like this:

    if ((status != 0) || (type_returned == None))
        return 0;       /* XGetWindowProperty failed */

    XFree(wid);
    return 1;  /* Return int, not window for this usage */

This allows the memory to be freed before exiting the function.
Previously, the xfree was not done, hence the slow leak.

For anyone who cares:

I emulated the WAIT3 function by using some code to tell if the DECWindows
pause screen was active.  This apparently thanks to Pat Mahan
(mahan@tgv.com).  This function was made to return a window id, but I
couldn't get that to work, so I changed it to make it return just an integer
yes/no, which is all I needed for this application anyway.  Unfortunately, I
bypassed the step that freed up the x-memory which was used.  This was not
apparent to me at the time, as you only need to free it up if the window
was present, but not if the window was not present.  I'm not a C or X
person, so I just saw the logic of the routine.  It seemed me that
all the calls were done, and now you were just evaluating what to return.
Being a slow memory leak, there did not appear to be a problem.
I'm in the habit of logging out every night, so it never grew to be big
enough for me to notice.

 Brian D. Reed    bdr@cbnewsg.cb.att.com

