CPU 99% Usage

Hi Ray! I noticed that strongly overloaded processor,nearly 100%.Even when I am commenting drawing code - 50% CPU
Sorry for bad english.
For example


  • Hi dzanis! Thanks for your feedback!

    That's related to GLFW3, main while loop is continuously polling for events (inputs, window, etc.), it's the expected behaviour...

    Here it is some more information on this issue: https://github.com/raysan5/raylib/issues/17
  • Hi Ray! It is not good, it does not have time for logic. :neutral: If I have free time, then I try to replace GLFW to SDL2.Can I do this? :smile:
  • edited October 2016
    Hi dzanis!

    Actually, it's good, most games work this way. It just keep checking for events while there is no other work to do, if there is extra logic, it works on the logic. Some more references about this:


    About SDL2, actually, it will be a full replacement for raylib. SDL2 offers mostly the same functionality as raylib, not only window/input management like GLFW3.
  • Hi. The problem was solved !!! Just commented the line // # define SUPPORT_BUSY_WAIT_LOOP, file core.c in the function Wait .And now CPU < 3%
  • Hi dzanis!

    I was wrong on my previous comments, my fault. Actually high CPU usage was related to my busy wait loop, it was possible to improve that behaviour using system halt instructions (like Sleep(), usleep(), nanosleep()). Just improved that code part.

    The problem I find now is that using Sleep() on windows sometimes locks framerate to 30 fps, don't know why. Need to investigate a bit more this issue...

    Glad to read that it works good for you.

    By the way, current implementation, it's quite the same used by SDL2.
  • Thank you for making such an option as in SDL.
    "locks framerate to 30 fps" I'm still just learning, and I can not help much. But maybe the solution here is in SDL_Delay

    And I overload the processor with examples of physics, but so far this is not very important.
  • SDL_Delay(), that's exactly the function I used for reference, windows and linux versions. In raylib it's called just Wait(). :)
Sign In or Register to comment.