[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pygame] (FWD) memory leak? P.S.




Ok. This bug now has me baffled and irritated. I've spent the last
three hours running windows python scripts and rebooting. Here is a
minimal program that displays the bug:

<crashy code>
import pygame
pygame.init()
rect = pygame.Rect(0, 240, 32, 32)
while 1: 
    for x in range(0, 608):
	 rect.left = x
</crashy code>

That's it. Note the following weird stuff:

1) It didn't crash when I commented out the rect= and rect.left=
lines.

2) It didn't crash when I commented out everything but the import and
pygame.init lines. I had assumed that the bug was in init.

3) Creating a display object doesn't matter - it crashes with or
without one.

So it looks like the bug is in rect. There's only one problem - Mark
Kimsel said he found the bug when working on a cd player - presumably
one that had no use for rect!

If you want a more entertaining example that displays the bug, here:

<crashy code>
import pygame
from pygame.locals import *

WHITE = (255, 255, 255, 255)
BLACK = (0, 0, 0, 255)
BLUE = (0, 0, 255, 255)

pygame.init()

display = pygame.display.set_mode( (640, 480), 0)

block_rect = pygame.Rect(0, 240, 32, 32)

while 1: 
        for x in range(0, 608):
                display.fill(BLUE, block_rect)
                pygame.display.update(block_rect)
                display.fill(BLACK, block_rect)
                pygame.display.update(block_rect)
                block_rect.left = x
</crashy code>

Run this about 15 times, aborting after around 30 seconds each
time. Then the last time it runs, watch the blue square get slower and
slower, until it (and your computer freezes). Could the bug be in the
import??

Also, in contrast to what Mr. Kimsel said, my resource monitor showed
a sudden drop in available memory a few seconds before the crash -
around 10 MB or so.


David Clark
silenus@telus.net
-- 
There are actually four certainties in life:
	Death, Taxes, Adultery and Advertising.
Everyone you care about will die.
Everything you earn will be taken from you at gunpoint.
Everyone you love will betray you.
Everything that matters to you will be packaged and sold.

____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org