import pygame
from pygame.locals import *

pygame.init()

pygame.display.set_caption('Possible memory leak')

FrameNumber = 0
DefaultFont = pygame.font.SysFont('verdana', 24, bold=True)
windowSurface = pygame.display.set_mode( (600, 500), 0, 32)

while True:
    # check for the QUIT event
    for event in pygame.event.get():
        if event.type == QUIT:
            pygame.quit()

        if event.type == KEYUP:
            if event.key == K_ESCAPE:
                pygame.quit()

    FrameNumber+=1

    windowSurface.fill( (0,0,255) )

    text = DefaultFont.render('Frame %d' % FrameNumber, True, (0,0,0), (0,0,255) )
    textrect = text.get_rect()
    textrect.left = 50
    textrect.top = 50

    windowSurface.blit(text, textrect )

    # If the next line is blanked, the memory leak is gone
    pygame.image.save (windowSurface, 'Frame%05d.png' )

    # draw the window onto the screen
    pygame.display.update()
