Article View: comp.lang.postscript
Article #8807pscal memory leaks
From: Stephen Mann
Date: Thu, 11 Jan 1990 04:33
Date: Thu, 11 Jan 1990 04:33
50 lines
1868 bytes
1868 bytes
After posting my latest version of pscal, I discovered that it failed to
work as advertised: if you tried to print an entire year, it would only
print the last 3 months of that year.
It turns out there are a couple of memory leaks, or rather, procedures that
leave things on the stack. These leaks aren't in the oldest version I have:
they appear to have been introduced when the calendar format was changed
to the current format (the original format drew about 10 horizontal lines
for each day instead of a box). The leaks aren't bad enough to affect
the printing of a single calendar page, but when multiple pages are
printed you get a stackoverflow error.
Anyway, one leak is in drawgrid, the other in drawfill. Both are in for
loops that don't use their loop control variables; the loop control variable
is left on the stack. In both cases you merely need to add a 'pop' on entering
the loop. More precisely, the following changes will eliminate the leaks:
In drawgrid change
0 1 5 {
gsave
100 0 rlineto
to
0 1 5 {
pop
gsave
100 0 rlineto
and in drawfill change
0 1 start 1 sub {
gsave
.9 setgray
to
0 1 start 1 sub {
pop
gsave
.9 setgray
I emailed a few people a "patched" version that put a mark on the stack and
cleared to the mark everytime it printed a page. Those versions will work
just fine; however, go ahead and make the above changes if you like.
Steve
Technical Details
Message-ID:
<10339@june.cs.washington.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!rice!uw-beaver!uw-june!smannShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!rice!uw-beaver!uw-june!smann From: smann@cs.washington.edu (Stephen Mann) Newsgroups: comp.lang.postscript Subject: pscal memory leaks Keywords: drawgrid, drawfill Message-ID: <10339@june.cs.washington.edu> Date: 11 Jan 90 04:33:58 GMT Distribution: na Organization: U of Washington, Computer Science, Seattle Lines: 50