rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
* Re:  memory leaks
@ 1992-08-13  3:44 Byron Rakitzis
  1992-08-13  7:28 ` Scott Schwartz
  0 siblings, 1 reply; 7+ messages in thread
From: Byron Rakitzis @ 1992-08-13  3:44 UTC (permalink / raw)
  To: rc, uunet!groucho.cs.psu.edu!schwartz

>Is anyone (besides me) concerned about the memory leaks in rc1.4?

I'm always interested in patching up a memory leak in rc.

>What do other shells do about this?

Presumably they don't leak.

>Depressing.  

Well, instead of being depressed about it you could send me some mail
with a full bug report.

I just looked at my rc-1.4 and I could not get it to leak on ^C. If you
gave described the problem in full (are you using readline, maybe a
prompt function doing something funny, etc.?) maybe somebody could do
something about it.

(BTW, I hate to say this, but it peeves me a bit that you refer to the
leak in the plural. Perhaps there is more than one memory leak left in
rc, but you only mentioned one in your mail. If you're going to talk
about memory leaks in the plural at least you could point out how to
tickle them.)

Byron.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: memory leaks
  1992-08-13  3:44 memory leaks Byron Rakitzis
@ 1992-08-13  7:28 ` Scott Schwartz
  0 siblings, 0 replies; 7+ messages in thread
From: Scott Schwartz @ 1992-08-13  7:28 UTC (permalink / raw)
  To: Byron Rakitzis; +Cc: rc


| Well, instead of being depressed about it you could send me some mail
| with a full bug report.

Sorry.  I needed to play empire for a while first. :-)

| I just looked at my rc-1.4 and I could not get it to leak on ^C. If you
| gave described the problem in full (are you using readline, maybe a
| prompt function doing something funny, etc.?) maybe somebody could do
| something about it.

I'm running vanilla 1.4 on a Sun sparc2 under 4.1.1, configured by
typing ``cp config.h-dist config.h''.   My prompt just prints status if
error.  Enclosed are some typescripts, one with an empty environment.
My supposition is that rc is longjmping out of an activation record
that has dynamically allocated some memory when it handles the sigint.

Script started on Thu Aug 13 03:05:27 EDT 1992
; exec ./rc-1.4-sun4
; ps v$pid
  PID TT STAT  TIME SL RE PAGEIN SIZE  RSS   LIM %CPU %MEM COMMAND
26690 rf S     0:00  0  8      0   76  320    xx  0.0  2.2 rc
; ^C
; ps v$pid
  PID TT STAT  TIME SL RE PAGEIN SIZE  RSS   LIM %CPU %MEM COMMAND
26690 rf S     0:00  0 15      0   76  324    xx  0.0  2.2 rc
; ^C
; ps v$pid
  PID TT STAT  TIME SL RE PAGEIN SIZE  RSS   LIM %CPU %MEM COMMAND
26690 rf S     0:00  0 22      0   80  320    xx  0.0  2.2 rc
; ^C
; ps v$pid
  PID TT STAT  TIME SL RE PAGEIN SIZE  RSS   LIM %CPU %MEM COMMAND
26690 rf S     0:00  0 30      0   80  324    xx  0.0  2.2 rc
; ^C
; ps v$pid
  PID TT STAT  TIME SL RE PAGEIN SIZE  RSS   LIM %CPU %MEM COMMAND
26690 rf S     0:00  0 36      0   84  324    xx  0.0  2.2 rc
; ^C
; ^C
; ^C
; ^C
; ^C
; ^C
; ^C
; ^C
; ^C
; ^C
; ps v$pid
  PID TT STAT  TIME SL RE PAGEIN SIZE  RSS   LIM %CPU %MEM COMMAND
26690 rf S     0:00  0 51      0  108  348    xx  0.0  2.4 rc
; Script done on Thu Aug 13 03:07:02 EDT 1992

Script started on Thu Aug 13 03:09:45 EDT 1992
; env - ./rc-1.4-sun4
; ps v$pid
  PID TT STAT  TIME SL RE PAGEIN SIZE  RSS   LIM %CPU %MEM COMMAND
26717 p6 S     0:00  0 10      0   56  284    xx  0.0  1.9 rc
; ^C
; ^C
; ^C
; ^C
; ^C
; ^C
; ^C
; ^C
; ^C
; ^C
; ps v$pid
  PID TT STAT  TIME SL RE PAGEIN SIZE  RSS   LIM %CPU %MEM COMMAND
26717 p6 S     0:00  0 22      0   80  308    xx  0.0  2.1 rc
; Script done on Thu Aug 13 03:10:23 EDT 1992

| (BTW, I hate to say this, but it peeves me a bit that you refer to the
| leak in the plural. 

Sorry about that.   I was speaking in generalities, "memory leaks"
being a single concept of which I discovered an instance.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: memory leaks
@ 1992-08-13 13:34 Chet Ramey
  0 siblings, 0 replies; 7+ messages in thread
From: Chet Ramey @ 1992-08-13 13:34 UTC (permalink / raw)
  To: schwartz; +Cc: rc, chet

> Is anyone (besides me) concerned about the memory leaks in rc1.4?  If
> you hit ^C you can watch your process size go up.  Depressing.  What do
> other shells do about this?

Bash has a fairly nice `unwind-protect' mechanism.  The interrupt handler
runs the unwind-protect list.  Bash is full of calls like

	begin_unwind_frame("tag");
	add_unwind_protect(free, string1);
	add_unwind_protect(close, openfd);
	add_unwind_protect (restore_signal_mask, oset);

		...

	run_unwind_frame("tag");

Look in the source file `unwind_prot.c' in the bash distribution.

ash and sh have a mechanism to `mark the stack' when allocating memory.
Then when they want to free it, they just unwind back to the previous
mark.

Chet

--
``The use of history as therapy means the corruption of history as history.''
	-- Arthur Schlesinger

Chet Ramey, Case Western Reserve University	Internet: chet@po.CWRU.Edu


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: memory leaks
  1992-08-13  7:56   ` Scott Schwartz
@ 1992-08-13 10:30     ` Mark-Jason Dominus
  0 siblings, 0 replies; 7+ messages in thread
From: Mark-Jason Dominus @ 1992-08-13 10:30 UTC (permalink / raw)
  To: Scott Schwartz; +Cc: The rc Mailing List, mjd


> Hmmm.  Maybe there is something system specific involved?  I tested
> it on a sparc2 with gcc 2.2.2.

Ditto on our sparc2 and 690MP, with out-of-the-box config.h-dist and gcc v2.1.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: memory leaks
  1992-08-13  4:32 ` John Mackin
@ 1992-08-13  7:56   ` Scott Schwartz
  1992-08-13 10:30     ` Mark-Jason Dominus
  0 siblings, 1 reply; 7+ messages in thread
From: Scott Schwartz @ 1992-08-13  7:56 UTC (permalink / raw)
  To: John Mackin; +Cc: The rc Mailing List


| Scott says his rc leaks memory on interrupts.  Like Byron, I can't duplicate
| this.  

Hmmm.  Maybe there is something system specific involved?  I tested
it on a sparc2 with gcc 2.2.2.

| Scott, could it be a startup thing?

I don't think so.  It grows on every ^C.  One of the typescripts I just
posted starts with an empty environment; no prompt function or other
junk.

| I tried this with 1.4.  Do a ps l of your rc, then in another window
| (to avoid observer effect) run "for (x in `{seq 1000}) kill -2 <the-pid>".
| Do another ps.  It doesn't grow.

Hmmm.  It just did for me:

Script started on Thu Aug 13 03:45:18 EDT 1992
; ps v26812
  PID TT STAT  TIME SL RE PAGEIN SIZE  RSS   LIM %CPU %MEM COMMAND
26812 q1 I     0:00 41 99      0   96  340    xx  0.0  2.3 rc
; kill -2 26812
; ps v26812
  PID TT STAT  TIME SL RE PAGEIN SIZE  RSS   LIM %CPU %MEM COMMAND
26812 q1 S     0:00  3 99      0   96  344    xx  0.0  2.3 rc
; kill -2 26812
; ps v26812
  PID TT STAT  TIME SL RE PAGEIN SIZE  RSS   LIM %CPU %MEM COMMAND
26812 q1 S     0:00  5 99      0  100  344    xx  0.0  2.3 rc
; Script done on Thu Aug 13 03:45:56 EDT 1992



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: memory leaks
  1992-08-13  2:08 Scott Schwartz
@ 1992-08-13  4:32 ` John Mackin
  1992-08-13  7:56   ` Scott Schwartz
  0 siblings, 1 reply; 7+ messages in thread
From: John Mackin @ 1992-08-13  4:32 UTC (permalink / raw)
  To: The rc Mailing List

Scott says his rc leaks memory on interrupts.  Like Byron, I can't duplicate
this.  Scott, could it be a startup thing?  Don't forget that rc, quite
legitimately, grows at first when you do things.  That's not a leak,
because it doesn't _keep_ growing when you _keep_ doing them.  As Byron
pointed out to me at one stage:

--- begin included message
From: Byron Rakitzis <byron@archone.tamu.edu>
Date: Thu, 27 Jun 1991 01:33:33 -0500
To: john@syd.dit.csiro.au
Subject: Re:  rc memory leaks
Received: from ARCHONE.TAMU.EDU by ditsydh.syd.dit.csiro.au with SMTP id AA17099
  (5.64+/IDA/DIT-0.9 for john); Thu, 27 Jun 91 16:33:56 +1000
Received: by archone.tamu.edu id <22531>; Thu, 27 Jun 1991 01:33:45 -0500
Message-Id: <91Jun27.013345cdt.22531@archone.tamu.edu>

Re: sun rc growing slowly. I find that when I start up a copy of rc and
type a few things at it, it grows. However, the real test for a memory
leak is to type the same command 1000 times. Does the shell grow in this
case?

(of course, you don't type the same command 1000 times, you . a file with
the command written out 1000 times)

[...]
--- end included message

I tried this with 1.4.  Do a ps l of your rc, then in another window
(to avoid observer effect) run "for (x in `{seq 1000}) kill -2 <the-pid>".
Do another ps.  It doesn't grow.

How do you reproduce it, Scott?

OK,
John.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* memory leaks
@ 1992-08-13  2:08 Scott Schwartz
  1992-08-13  4:32 ` John Mackin
  0 siblings, 1 reply; 7+ messages in thread
From: Scott Schwartz @ 1992-08-13  2:08 UTC (permalink / raw)
  To: rc

Is anyone (besides me) concerned about the memory leaks in rc1.4?  If
you hit ^C you can watch your process size go up.  Depressing.  What do
other shells do about this?

-- Scott


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~1992-08-13 13:45 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1992-08-13  3:44 memory leaks Byron Rakitzis
1992-08-13  7:28 ` Scott Schwartz
  -- strict thread matches above, loose matches on Subject: below --
1992-08-13 13:34 Chet Ramey
1992-08-13  2:08 Scott Schwartz
1992-08-13  4:32 ` John Mackin
1992-08-13  7:56   ` Scott Schwartz
1992-08-13 10:30     ` Mark-Jason Dominus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).