pscal memory leaks 
Author Message
 pscal memory leaks

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



Mon, 29 Jun 1992 12:33:58 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Dial Up Connections Windows98

2. TP Conversion to Visual Basic

3. Foxpro databases & Delphi ??

4. DBverticalGrid

5. Database Independent Development in Delphi 2.0 ????

6. Extended Pascal and generalized assertions

7. ACCESS-JetEngine - component ??

8. GetPixel 320*200*256*4 ???

9. Turbo 3 Serial Communication

10. 'Delphi does dos' - compile and debug BP7 protected mode programs under D1.

11. Save over 50%

12. Links Related To comp.lang.pascal.misc - FREE ACCESS 0219

 

 
Powered by phpBB® Forum Software