[Python] Why do I get a BadAlloc error from pygame.display.set_mode()?

Discussão em 'Python' iniciado por Stack, Agosto 14, 2025.

  1. Stack

    Stack Membro Participativo

    I installed Thonny and tried running my Python project, but I get an error from this line:

    fenster=pygame.display.set_mode((Multiplikator*W, Multiplikator*H))


    Multiplikator, W and H are defined further up in the code. I get:

    X Error: BadAlloc
    Request Major code 149 ()
    Request Minor code 2
    Error Serial #165
    Current Serial #166

    Process ended with exit code 1.


    Previously this code would run fine. Is it because I am using a newer version of Thonny? BadAlloc is related to system resources being too low, but the laptop has 16GB RAM and only about 2.5 are used. NumPy and Pygame are correctly installed.

    Continue reading...

Compartilhe esta Página