SFML community forums

Help => General => Topic started by: efeXor on January 16, 2009, 04:02:26 am

Title: 48% CPU USAGE!
Post by: efeXor on January 16, 2009, 04:02:26 am
After doing the render window tutorial i get like 48% cpu usage. Why and how can i fix?
Title: 48% CPU USAGE!
Post by: Daazku on January 16, 2009, 04:05:44 am
48% while the app is running or after?

Because if its while the app is running its totally normal.....
Title: 48% CPU USAGE!
Post by: klusark on January 16, 2009, 04:07:54 am
It trying to render as fast as it can. You could limit the frame rate by adding waits to each loop.
Title: 48% CPU USAGE!
Post by: efeXor on January 16, 2009, 04:31:10 am
Quote from: "Daazku"
48% while the app is running or after?

Because if its while the app is running its totally normal.....


how is that in any way normal?
Title: 48% CPU USAGE!
Post by: klusark on January 16, 2009, 05:00:32 am
Quote from: "efeXor"
Quote from: "Daazku"
48% while the app is running or after?

Because if its while the app is running its totally normal.....


how is that in any way normal?

Take a look at any game. What is your cpu usage at while its running?
Title: 48% CPU USAGE!
Post by: Wizzard on January 16, 2009, 07:46:29 am
Quote from: "Avency"
To solve the problems, you can try to:

1. set a framerate limit (sf::RenderWindow::SetFramerateLimit)
2. enable vertical synchronization (sf::RenderWindow::UseVerticalSync)
3. write your own framelimiting code (sf::Sleep)

I hope that helps.
Title: 48% CPU USAGE!
Post by: Laurent on January 16, 2009, 07:58:39 am
Quote
how is that in any way normal?

The program consists of an endless loop that never pauses. It simply eats all the CPU it can.
Title: 48% CPU USAGE!
Post by: Nexus on January 16, 2009, 01:23:36 pm
Have you got a dual core processor? Single core processors can even be working to capacity with infinite loops.

Follow one of Avency's steps. I use sf::Sleep and in release mode, the CPU usage is less than 5% (about 33 FPS and dual core).