Article View: news.software.readers
Article #522xrn, memory hog
From: Jim Rees
Date: Fri, 23 Aug 1991 14:11
Date: Fri, 23 Aug 1991 14:11
67 lines
3151 bytes
3151 bytes
I got to wondering why xrn seems to leak memory, and decided to investigate.
On my system (Apollo Domain/OS) it grows from 5 Mb up to 20 Mb or more by
the end of the day.
I put a trace on malloc/free and found two things. The first is that the
code that is supposed to free the space allocated for article text doesn't
work. It's written correctly, but the value of the XtNstring resource
always comes back NULL. This appears to be a bug in the text widget, but I
haven't tracked it down because the workaround is easy. It may be a generic
text widget bug or just an implementation bug on my system, I don't know.
My fix is at the end of this article.
The other thing I found is that getarticles(), in server.c, allocates huge
chunks of storage to store information about each article (subject, author,
etc.). This storage sometimes gets freed, sometimes not. The logic is not
easy (for me) to follow, but I think there must be a leak here. There
doesn't seem to be any other place where enough storage gets allocated to
account for the size leak I'm seeing.
Here is a fix for the leak in redrawArticleWidget():
% diff -cb src/buttons.c buttons.c
*** src/buttons.c Wed Feb 20 13:18:45 1991
--- buttons.c Fri Aug 23 09:42:34 1991
***************
*** 2824,2830 ****
Arg args[5];
int fildes;
struct stat buf;
! char *olddata, *data;
if (filename != LastArticle) {
LastArticle = filename;
--- 2824,2831 ----
Arg args[5];
int fildes;
struct stat buf;
! char *data;
! static char *olddata;
if (filename != LastArticle) {
LastArticle = filename;
***************
*** 2850,2861 ****
XawTextSetSource(ArticleText, ArtSource, (XawTextPosition) 0);
XawTextSetSelectionArray(ArticleText, allSelectArray);
} else {
- XtVaGetValues(ArtSource,
- XtNstring, &olddata,
- NULL);
- XtFree(olddata);
XtSetValues(ArtSource, args, XtNumber(args));
}
#else
/* destroy the old text file window */
if (ArtSource != 0) {
--- 2851,2860 ----
XawTextSetSource(ArticleText, ArtSource, (XawTextPosition) 0);
XawTextSetSelectionArray(ArticleText, allSelectArray);
} else {
XtSetValues(ArtSource, args, XtNumber(args));
+ XtFree(olddata);
}
+ olddata = data;
#else
/* destroy the old text file window */
if (ArtSource != 0) {
Technical Details
Message-ID:
<538ad706.1bc5b@pisa.citi.umich.edu>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.readers.mbox.zip!gmdzi!unido!unidui!math.fu-berlin.de!ox.com!yale.edu!think.com!samsung!umich!terminator!pisa.citi.umich.edu!reesShow Full Headers
Complete Article Headers
Message-ID: <538ad706.1bc5b@pisa.citi.umich.edu> Subject: xrn, memory hog Date: Fri, 23 Aug 1991 14:11:44 +0000 From: rees@pisa.citi.umich.edu (Jim Rees) Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.readers.mbox.zip!gmdzi!unido!unidui!math.fu-berlin.de!ox.com!yale.edu!think.com!samsung!umich!terminator!pisa.citi.umich.edu!rees Newsgroups: news.software.readers Sender: usenet@terminator.cc.umich.edu (usenet news) Reply-To: rees@citi.umich.edu (Jim Rees) Organization: University of Michigan IFS Project Lines: 67