🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.readers
1 messages
1 total messages Started by Clifton Royston Tue, 27 Sep 1994 23:38
Patch for excessive memory usage in Tin1.22
#11606
Author: Clifton Royston
Date: Tue, 27 Sep 1994 23:38
120 lines
4678 bytes
  I just posted this to a mailing list I'm on, so I thought I would repost
it here, since it's been a long time.  I would assume that this has been
fixed in the long-awaited Tin 1.30, since Iain got a copy of this fix last
year.

  As you'll see below, I didn't write this one, but all reports are that it
works fine.  This code should only be called if the NNTP "newgroups" command
is not available, which should only be true if running on a local file or
NFS based news spool.  Tin can be sloppy about memory usage, but this is the
only situation I know of (at present) when it would suddenly balloon its
memory image by several MB like this, in the course of checking for new
groups.

  Last year when I was still working on Tin actively, all the reports of
bloated memory usage were coming from local spool systems like Netcom's. 
I'm surprised that some NNTP users are having troubles and some not.  (Maybe
it depends on whether you're using NOV, central TIN index, or local indexes?
Pure guess.)

  Patch follows.
  -- Clifton

-- 
cliftonr@netcom.com     Phone: +1 808 521 9073
Clifton Royston  --  President, LavaNet Inc.

From: hawkeye@glia.biostr.washington.edu (Ken Keys)
Posted-Date: Sun, 5 Dec 93 21:20:54 PST
Message-Id: <9312060520.AA07331@glia.biostr.washington.edu>
Subject: Patch to tin 1.22
To: iain.lea@erlm.siemens.de
Date: Sun, 5 Dec 93 21:20:54 PST
Cc: sterling@oldcolo.com, cliftonr@netcom.com
X-Mailer: ELM [version 2.3 PL11]
Status: RO

At the request of Bruce Sterling Woodcock (sterling@oldcolo.com), I
wrote a patch that signifigantly reduces the memory usage of the
program.  In the t_notice structure, instead of delaring name with
length MAXPATHLEN, I allocate it dynamically.  I figure this is an
average of 20 bytes (plus malloc overhead) per group, instead of 1024.
For ~4000 groups, that's a BIG savings.
 
-- 
Ken "Hawkeye" Keys                  |  If you use TinyFugue, help support it.
hawkeye@glia.biostr.washington.edu  |  Send donations to:  Ken Keys
------------------------------------+-------------+        1820 Cottonwood Av.
Official TF ftp site: glia.biostr.washington.edu  |        Carlsbad CA 92009


diff -c tin-1.22/active.c tin-ksk/active.c
*** tin-1.22/active.c	Sat Sep 25 07:30:08 1993
--- tin-ksk/active.c	Sun Dec  5 20:44:44 1993
***************
*** 524,535 ****
  		if (buf[0] == '.') {
  			break;
  		}
! 		strncpy (old_active[num].name, buf, sizeof (old_active[num].name));
! 		ptr = old_active[num].name;
  		while (*ptr && *ptr != ' ' && *ptr != '\n') {
  			ptr++;
  		}
! 		*ptr = '\0';
  		old_active[num].visited = FALSE;
  		num++;
  		if (num >= max_old_active) {
--- 524,545 ----
  		if (buf[0] == '.') {
  			break;
  		}
! 
! 		ptr = buf;
  		while (*ptr && *ptr != ' ' && *ptr != '\n') {
  			ptr++;
  		}
! 
! 		/*
! 		 * The average length of a name including '\0' is around 20 bytes.
! 		 * So instead of using an array of length MAXPATHLEN (==1024),
! 		 * we allocate only what we need here.  For 4000 group names,
! 		 * this reduces the process size by over 3.8 M.  --Ken Keys
! 		 */
! 		old_active[num].name = (char *) my_malloc(ptr - buf + 1);
! 		strncpy(old_active[num].name, buf, ptr - buf);
! 		old_active[num].name[ptr - buf] = '\0';
! 
  		old_active[num].visited = FALSE;
  		num++;
  		if (num >= max_old_active) {
***************
*** 731,736 ****
--- 741,748 ----
  	 * Free malloc'd arrays
  	 */
  	if (old_active != (notify_p) 0) {
+ 		for (i = 0; i < num; i++)
+ 			free (old_active[i].name);
  		free ((char *) old_active);
  		old_active = (notify_p) 0;
  	}
diff -c tin-1.22/tin.h tin-ksk/tin.h
*** tin-1.22/tin.h	Sat Sep 25 07:30:04 1993
--- tin-ksk/tin.h	Sun Dec  5 17:19:04 1993
***************
*** 1040,1046 ****
  
  struct t_notify
  {
! 	char name[PATH_LEN];
  	int visited;
  };
  
--- 1040,1046 ----
  
  struct t_notify
  {
! 	char *name;
  	int visited;
  };
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