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

Author Topic: Anyone tell me why SFML slows down over time?  (Read 10164 times)

0 Members and 2 Guests are viewing this topic.

wicked357

  • Newbie
  • *
  • Posts: 18
    • View Profile
    • http://www.eternalcoding.com
Anyone tell me why SFML slows down over time?
« on: May 10, 2010, 12:10:58 pm »
I have noticed that my SFML project slows down overtime, but there is a kicker here it only does this on my desktop and not my laptop. The difference between the two, desktop can run Crysis on max settings and my laptop cannot even play Crysis period. I am just running a simple SFML application bare minimums just drawing an image and moving it via keyboard input. On my laptop it runs smooth no problems at all, but on the desktop it slows down considerably the longer it is running. Anyone know what is causing this on my desktop?

EDIT** Oh yea btw, I used to not have this problem, and I am still running the same OS.

panithadrum

  • Sr. Member
  • ****
  • Posts: 304
    • View Profile
    • Skyrpex@Github
    • Email
Anyone tell me why SFML slows down over time?
« Reply #1 on: May 10, 2010, 12:54:02 pm »
Maybe memory leaks? I can't tell without code...

wicked357

  • Newbie
  • *
  • Posts: 18
    • View Profile
    • http://www.eternalcoding.com
Anyone tell me why SFML slows down over time?
« Reply #2 on: May 10, 2010, 01:06:53 pm »
Wait? Memory leaks affects my desktop only? not my laptop?

wicked357

  • Newbie
  • *
  • Posts: 18
    • View Profile
    • http://www.eternalcoding.com
Anyone tell me why SFML slows down over time?
« Reply #3 on: May 10, 2010, 01:23:58 pm »
Here is the code I have it is basic and simple same code I can run on my laptop at perfect performance.

Code: [Select]

#include <SFML/Graphics.hpp>

int main()
{
sf::RenderWindow Game(sf::VideoMode(800, 600, 32), "SFML");

sf::Event Event;

sf::Image image;
sf::Sprite sprite;

if(!image.LoadFromFile("player.png"))
return 1;
sprite.SetImage(image);

while(Game.IsOpened())
{
while(Game.GetEvent(Event))
{
if(Event.Type == sf::Event::Closed)
Game.Close();
}

if(Game.GetInput().IsKeyDown(sf::Key::Escape))
Game.Close();

if(Game.GetInput().IsKeyDown(sf::Key::W))
sprite.Move(sf::Vector2f(0, -1));
else if(Game.GetInput().IsKeyDown(sf::Key::S))
sprite.Move(sf::Vector2f(0, 1));
if(Game.GetInput().IsKeyDown(sf::Key::A))
sprite.Move(sf::Vector2f(-1, 0));
else if(Game.GetInput().IsKeyDown(sf::Key::D))
sprite.Move(sf::Vector2f(1, 0));

Game.Clear();

Game.Draw(sprite);

Game.Display();
}

return EXIT_SUCCESS;
}

panithadrum

  • Sr. Member
  • ****
  • Posts: 304
    • View Profile
    • Skyrpex@Github
    • Email
Anyone tell me why SFML slows down over time?
« Reply #4 on: May 10, 2010, 02:03:01 pm »
The code is ok... then I don't have idea why it slows down :-S. Let's check what is slowing it:
Try the same code without any image and sprite in it. Then without clearing and displaying. You know what I mean?

wicked357

  • Newbie
  • *
  • Posts: 18
    • View Profile
    • http://www.eternalcoding.com
Anyone tell me why SFML slows down over time?
« Reply #5 on: May 10, 2010, 02:17:06 pm »
Nothing stops the slow down process at all, it start about 700 fps goes up to about ~1200 then starts counting down fast, until it is less than 100 fps and nothing is being drawn to the game screen and nothing is being loaded up just creating the game window, no event, no keyboard input, nothing. I cannot test clear and display as my fps from fraps wont show up anymore if you dont use either of those, well clear will make the fps unreadable. I am officially stumped on this one.

Ashenwraith

  • Sr. Member
  • ****
  • Posts: 270
    • View Profile
Anyone tell me why SFML slows down over time?
« Reply #6 on: May 10, 2010, 04:51:11 pm »
What are you using to draw the fps?

Here's my opinion, maybe Laurent can speak up and tell me where I'm wrong:

fps is used for 3D games to show a smooth framerate despite having lots of effects or to compare hardware handling the same effects.

Trying to rev up lots of fps on a blank/almost empty screen is pointless.

The engine isn't built on giving you the max fps of a blank screen, but instead having a massive amount of sprites/sprite data and keeping the fps around 60.

In a 3D game you have can have static cameras and geometry where nothing or little is changing. SFML is written to always be changing, but at a constant rate.

wicked357

  • Newbie
  • *
  • Posts: 18
    • View Profile
    • http://www.eternalcoding.com
Anyone tell me why SFML slows down over time?
« Reply #7 on: May 10, 2010, 05:00:51 pm »
This really isn't about the FPS being calculated, this is about SFML slowing down on my desktop which is far more powerful than my laptop and my laptop runs that same code smoother and doesn't have a consistent slow down, for instance when I move the sprite around it starts out moving fast and gets to the point where it is moving like a snail and still getting slower.

Ashenwraith

  • Sr. Member
  • ****
  • Posts: 270
    • View Profile
Anyone tell me why SFML slows down over time?
« Reply #8 on: May 10, 2010, 06:52:30 pm »
It does matter what you use to draw fps, some people use the console and it can be really slow for that.

But if you're only having a problem with your laptop you should be giving us OS, driver/card specs.

Your desktop could have a crappy ATI card/driver or integrated graphics.

OpenGL tends to run better on NVIDIA and fullscreen--especially if your OS is Vista/Windows 7

Breakman79

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Anyone tell me why SFML slows down over time?
« Reply #9 on: May 10, 2010, 06:57:43 pm »
Are your video card drivers up-to-date?  I had a similar issue several years ago with an nvida driver that leaked memory whenever my opengl screensaver would run.  It would slow to a crawl while exhausting the memory until the computer crashed.

wicked357

  • Newbie
  • *
  • Posts: 18
    • View Profile
    • http://www.eternalcoding.com
Anyone tell me why SFML slows down over time?
« Reply #10 on: May 11, 2010, 12:30:56 pm »
As stated before I ran SFML fine before on my desktop before and I have the same hardware/software, the only thing I changed is my main monitor now is a 120hz Viewsonic for 3D and I enabled 3D Vision, I haven't tried disabling this as I didn't see it being the issue, but I guess you never know. My drivers are updated and I am running a Nvidia card not an ATI. I just noticed this issue about 1 week ago when I had to build a game real fast for a class I was taking, I had to do all my programming on my laptop and couldn't even run the game on my desktop due to being to slow.

Ashenwraith

  • Sr. Member
  • ****
  • Posts: 270
    • View Profile
Anyone tell me why SFML slows down over time?
« Reply #11 on: May 11, 2010, 01:28:13 pm »
Maybe your desktop is also your prime porn/warez computer and so you have malware/viruses?

If you take two identical machines one must be crippled if it has a problem.

Did you try running in fullscreen with xp emulated mode and see if you still have the problem?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Anyone tell me why SFML slows down over time?
« Reply #12 on: May 11, 2010, 01:32:14 pm »
You should try disabling 3D vision. SFML is 2D, but internally it uses 3D OpenGL primitives so it may be affected by this.
Laurent Gomila - SFML developer

wicked357

  • Newbie
  • *
  • Posts: 18
    • View Profile
    • http://www.eternalcoding.com
Anyone tell me why SFML slows down over time?
« Reply #13 on: May 12, 2010, 12:11:34 am »
Thanks for all the help everyone, I wanted to figure this out without a restore of my system, but I have installed so much different software and I have experienced a few malware, but I have since then cleansed my system and ran a registry fix program, but in the end I have had to restore my computer. I have been needing to do it anyways so I guess it is ok.

On the upside here the restore has officially fixed the problem, I was thinking maybe it was because I recently installed VS2010 C++ Express when my main compiler is VS2008 Pro, but not really sure I know sometimes things can be weird like that, so I just eliminated all possibilities and did a complete system restore. I can tell you Nvidia 3D Vision only slows the game up for about 1 minute than it runs perfectly fine afterwords, if I disable it, there is no 1 minute slow up. Thanks again for all your help I knew something was wrong no matter what it was probably a good idea I did a restore anyways.