🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.nntp
1 messages
1 total messages Started by Gary Palmer Mon, 30 Jun 1997 00:00
Memory leak in Clayton O'neill's HIScache patches
#18854
Author: 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

Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads