You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for the reproducer, that shows the real issue here.
The issue only happens when you do pygame.event.get(pygame.KEYDOWN) (AKA you are only handling KEYDOWN events and ignoring the rest)
When you are only handling particular events, the event queue can fill up with the events you don't handle and this increases memory usage (also there is a limit to how much the queue can grow so at one point it might overflow as the docs point out too).
So in general, you need to call pygame.event.get() atleast once per loop, but you can call pygame.event.get(pygame.KEYDOWN) before doing so, and doing this should fix your issue as well.
Internally, pygame generates the unicode property for every KEYDOWN and stores it till the corresponding KEYUP is given to the user. In order to not leak to much memory, there is a limit in pygame how many keydown unicode fields are stored (at the moment it is 15). To fix this issue, this limit will have to be lifted (along with a few more changes)
Thanks for the response and explanation. It seems that getting all events is not necessary, but that just also getting the KEYUP events (even though they are of no interest) will already solve the issue:
Issue №3229 opened by fladd at 2022-06-10 17:08:44
When getting key down events from the event cue, only a few keys have the "unicode" property filled with the correct key (most are empty).
Which keys have it and which don't, depends on which keys you press first:
And if you go from behind, this happens:
And if you do one key repeatedly:
System:
Windows 10
Python 3.9.5
Pygame 2.1.2
Comments
# # ankith26 commented at 2022-06-10 17:21:23
Hello, thanks for the bug report!
I can't reproduce this bug with a basic event example, could you please post a minimal reproducer that demonstrates your problem?
Also, are you pressing the keys simultaneously?
# # fladd commented at 2022-06-10 22:07:38
Here is a minimal example:
Run this, start pressing keys (one after the other, not simultaneously), and then watch the terminal output.
# # fladd commented at 2022-06-10 22:11:48
Also happens on MacOS with Python 3.10.4 and Pygame 2.1.2.
# # ankith26 commented at 2022-06-11 03:11:31
Thanks for the reproducer, that shows the real issue here.
The issue only happens when you do
pygame.event.get(pygame.KEYDOWN)
(AKA you are only handlingKEYDOWN
events and ignoring the rest)When you are only handling particular events, the event queue can fill up with the events you don't handle and this increases memory usage (also there is a limit to how much the queue can grow so at one point it might overflow as the docs point out too).
So in general, you need to call
pygame.event.get()
atleast once per loop, but you can callpygame.event.get(pygame.KEYDOWN)
before doing so, and doing this should fix your issue as well.Internally, pygame generates the unicode property for every
KEYDOWN
and stores it till the correspondingKEYUP
is given to the user. In order to not leak to much memory, there is a limit in pygame how many keydown unicode fields are stored (at the moment it is 15). To fix this issue, this limit will have to be lifted (along with a few more changes)# # fladd commented at 2022-06-11 22:08:24
Thanks for the response and explanation. It seems that getting all events is not necessary, but that just also getting the KEYUP events (even though they are of no interest) will already solve the issue:
The text was updated successfully, but these errors were encountered: