[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] BUG: pygame leaks memory (?)
- To: pygame-users@xxxxxxxx
- Subject: Re: [pygame] BUG: pygame leaks memory (?)
- From: Martin Kühne <mysatyre@xxxxxxxxx>
- Date: Tue, 20 Dec 2016 16:07:50 +0100
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Tue, 20 Dec 2016 10:08:14 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=E1xavofynnt+Ybyga0pC0rdW8W/xK6UAU3S3v0uUaEU=; b=uoVz7Vl8LhYmIaCWiSfGpkJWD5/hHW+sG6CAVzOLAB1g8jaoL95grcr1f7yFkZ3t5X NMe7vyXTQwr34se9vHB1ijPDhHEr9ASMW7IcZmwP1C9HKXAKqVqBvZnik2mUW69BAXSx l0QVmtCVdFHq9yL6XJmm5+TzfS7+4sDVx3Tnjf8J7RibLk7aPi98enCB2o/BhWeM3K/o AVHLd0fXfMhAMocnrWpwgy82cXtwKeCCupClfXezYFEUHZBcionCVw70UD0+3F/DUerH l2Mq7iZkxJNS9dOzaMilHIdG6862HSyZiab0LIKvFDzFBEUdxsSZ2XFVMYodtvAhPSDx f4FA==
- In-reply-to: <trinity-6cd5fda3-81fd-4161-b0c7-866921ef7b71-1482241006955@3capp-gmx-bs12>
- References: <trinity-6cd5fda3-81fd-4161-b0c7-866921ef7b71-1482241006955@3capp-gmx-bs12>
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
Use timers so you don't run on 100% CPU:
TIMER = pygame.NUMEVENT - 1
pygame.time.set_timer(TIMER, 50)
def show(self):
# this is a simple frame dropping logic, so that the event queue
empties per call of show()
# and within the time specified by pygame.time.set_timer
updated=False
for event in [pygame.event.wait(), *pygame.event.get()]:
if event.type == QUIT:
exit()
elif event.type == TIMER and not updated:
updated = True
# update graphic here
pygame.display.update()
I do find it surprising that pygame should be creating a memory leak
in this case, since none of the pygame functions you use,
pygame.event.get, pygame.Surface.fill, pygame.draw.rect are ones which
one would expect to permanently allocate memory for any obvious
reason.
cheers!
mar77i