Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: 48% CPU USAGE!  (Read 4376 times)

0 Members and 1 Guest are viewing this topic.

efeXor

  • Newbie
  • *
  • Posts: 10
    • MSN Messenger - Steam:BrokenGlassX
    • View Profile
48% CPU USAGE!
« 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?

Daazku

  • Hero Member
  • *****
  • Posts: 896
    • View Profile
48% CPU USAGE!
« Reply #1 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.....
Pensez à mettre le tag [Résolu] une fois la réponse à votre question trouvée.
Remember to add the tag [Solved] when you got an answer to your question.

klusark

  • Newbie
  • *
  • Posts: 45
    • View Profile
48% CPU USAGE!
« Reply #2 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.

efeXor

  • Newbie
  • *
  • Posts: 10
    • MSN Messenger - Steam:BrokenGlassX
    • View Profile
48% CPU USAGE!
« Reply #3 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?

klusark

  • Newbie
  • *
  • Posts: 45
    • View Profile
48% CPU USAGE!
« Reply #4 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?

Wizzard

  • Full Member
  • ***
  • Posts: 213
    • View Profile
48% CPU USAGE!
« Reply #5 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
48% CPU USAGE!
« Reply #6 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.
Laurent Gomila - SFML developer

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
48% CPU USAGE!
« Reply #7 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).
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development: