This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl 5.0 alpha 5
[perl5.git] / Bugs / substleak
CommitLineData
ed6116ce
LW
1Return-Path: Martin.Ward@durham.ac.uk
2Return-Path: <Martin.Ward@durham.ac.uk>
3Received: from scalpel.netlabs.com by netlabs.com (4.1/SMI-4.1)
4 id AA01931; Thu, 20 Jan 94 03:56:39 PST
5Received: from netlabs.com (vaccine-eng1.netlabs.com) by scalpel.netlabs.com (4.1/SMI-4.1)
6 id AA09639; Thu, 20 Jan 94 03:56:36 PST
7Received: from sun2.nsfnet-relay.ac.uk by netlabs.com (4.1/SMI-4.1)
8 id AA01923; Thu, 20 Jan 94 03:56:01 PST
9Via: uk.ac.durham; Thu, 20 Jan 1994 11:47:16 +0000
10Received: from easby.dur.ac.uk by durham.ac.uk; Thu, 20 Jan 94 11:47:05 GMT
11Received: from ws-csm3.durham.ac.uk (ws-csm3.dur) by uk.ac.durham.easby;
12 Thu, 20 Jan 94 11:46:29 GMT
13From: Martin.Ward@durham.ac.uk (Martin Ward)
14Date: Thu, 20 Jan 94 11:46:27 GMT
15Message-Id: <AA00871.9401201146.ws-csm3@uk.ac.durham>
16To: des0mpw@easby.durham.ac.uk, lwall@scalpel.netlabs.com
17Subject: Re: My last message
18
19>: After saying I was stumped, I managed to track down the problem!
20>: The problem was caused by a line much higher up:
21>:
22>: $seqpat = "$bs[s]\000e\000q\000\{\000"; # } hack
23>:
24>: Changing this by adding {} gives:
25>:
26>: $seqpat = "${bs}[s]\000e\000q\000\{\000"; # } hack
27>:
28>: which worked! No idea why :-)
29>
30>It apparently intuited $bs[s] to be an array reference.
31
32Aha! I think the interpretation is:
33"$bs[ s] .....
34^^^^^ ^^
35array ref Therefore this is an expression, so "s]" is the start of
36 a pattern match/replace, so it scans for ...]....]
37
38I found the line by repeatedly chopping away everything after (and including)
39the line where perl _thought_ the error started. This gradually worked back
40through a nasty cascade of errors!
41
42>: No speed improvement this time (the improvement in user time was swamped
43>: by an increase in system time. This may be because it uses 5048k of
44>: data/stack space, compared with 985k for perl4).
45>
46>That doesn't sound good. I hope it's a bug. Does it grow continuously?
47>Hopefully it's just a memory leak.
48
49For perl4 the memory size (shown by top) grows by about 100-150k per 2 seconds,
50for perl5 it grows by about 1 - 1.5 Meg per 2 seconds. I don't use the script
51very often (and I have over 100 Meg of swap space) so its not a big problem.
52Still, with a 124k input file, the size for perl5 went up to 40 Meg!
53
54I have tracked down a memory leak, which is basically one line from the
55texqed script. Store this script in "tmp" and run "perl tmp /vmunix"
56(or some other large random file). Monitor the process using "top" in
57another window.
58
59Perl4 is OK but perl5 leaks like a leaky cistern.
60
61
62#!/usr/local/bin/perl
63
64# print a "." every $interval lines:
65$interval = 10;
66open (PAIRS, "$ARGV[0]");
67open (OUT, "> /dev/null");
68$bs = "\\\\" . "\000";
69for (;;) {
70 $line++;
71 if (($line % $interval) == 0) {
72 print STDERR ".";
73 }
74 read(PAIRS, $_, 20);
75 last if ($_ eq "");
76
77 s/$bs([_^\\])\000/\\\377$1\377/g;
78
79 print OUT ;
80}
81
82print STDERR "\n";
83
84
85
86I hope you find this useful!
87
88NB Changing the "s/.../.../g" to an "m/.../" (with the same pattern)
89makes the leak go away even on input files where the pattern NEVER matches!!
90
91 Martin.
92
93JANET: Martin.Ward@uk.ac.durham Internet (eg US): Martin.Ward@durham.ac.uk
94or if that fails: Martin.Ward%uk.ac.durham@nsfnet-relay.ac.uk
95or even: Martin.Ward%DURHAM.AC.UK@CUNYVM.CUNY.EDU
96BITNET: Martin.Ward%durham.ac.uk@UKACRL UUCP:...!uknet!durham!Martin.Ward
97[Last acked 0.7 days ago--not acked]
98