🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #18854

Memory leak in Clayton O'neill's HIScache patches

#18854
From: Gary Palmer
Date: Mon, 30 Jun 1997 00:00
51 lines
2189 bytes
For those that are using the history cache patches, I have noticed a
rather subtle memory leak, but a nasty one nonetheless (it can ammount
to several MB's a day)

Cause:

HIScache malloc's memory (using strdup) for storage of the
Message-ID's for comparison to stop hash overlapping from rejecting
articles not already received. However, when the history file is
reloaded (e.g. by expire during news.daily), the history file is
closed (using HISclose) and re-opened using the HISsetup
function. Clayton's patch memset's the HIScache array back to 0 in the
HISsetup function. This loses all the pointers to the malloc'd areas
of memory for ever (unless you have a *VERY* smart malloc
implimentation).

Given an `average' Message-ID length of 80 characters (or is it 70? I
forget), you could lose up to 4.5Mb of core memory per reload if you
run with the default cache size.

Solution:

You need to do something like

/*
**  Set up the history files.
*/
void
HISsetup()
{
    static int HIScachezeroed = FALSE;

 ( .... )

    if (HIScachezeroed == FALSE) {
	memset((void *)&HIScache, '\0', sizeof(HIScache));
	HIScachezeroed = TRUE;
    }
}

This should stop the leakage. I have informed Clayton about this, but
I'm not sure if he is going to re-roll his patch as I believe his
sources have diverged too far from the baseline to generate a clean
diff. If there is interest, I could re-roll it with another local
change (it stops multiple transfers of articles for groups we don't
want)

Gary

Technical Details
Message-ID: <5p9h1p$mom@news.webspan.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail

Show Full Headers
Complete Article Headers
Message-ID: <5p9h1p$mom@news.webspan.net>
Subject: Memory leak in Clayton O'neill's HIScache patches
Date: Mon, 30 Jun 1997 00:00:00 +0000
From: gpalmer@SPAM.webspan.net (Gary Palmer)
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail
X-Deja-AN: 253724915
Sender: gpalmer@mutara.noc.webspan.net
X-Report-Abuse-To: abuse@mail.webspan.net
Organization: WebSpan Inc., New Jersey
NNTP-Posting-Date: 30 Jun 1997 19:55:37 EDT
Newsgroups: news.software.nntp