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

Author Topic: Basic window memory issue  (Read 3735 times)

0 Members and 1 Guest are viewing this topic.

Mörkö

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
Basic window memory issue
« on: May 28, 2014, 01:00:40 am »
On my system the following code seems to add 10mb or ram per second:

int main() {
    sf::RenderWindow window(sf::VideoMode(320, 240), "");
    sf::Event event;
    while (window.isOpen()) {
        while (window.pollEvent(event)) {
            if (event.type == sf::Event::Closed)
                window.close();
        }
        glClear(GL_COLOR_BUFFER_BIT);
        window.display();
    }
}

In my system monitor, running that shows a steady increase of +10mb memory usage every second. These are my specs:
             .;ldkO0000Okdl;.                user@box
         .;d00xl:,'....';:ok00d;.            OS: openSUSE 13.1 Bottle
       .d00l'                ,o00d.          Kernel: x86_64 Linux 3.11.10-11-desktop
     .d0Kd. :Okxol:;'.          :O0d.        Uptime: 3h 0m
    'OKKKK0kOKKKKKKKKKKOxo:'      lKO'       Packages: 2570
   ,0KKKKKKKKKKKKKKKK0d:,,,:dx:    ;00,      Shell: bash 4.2.45
  .OKKKKKKKKKKKKKKKKk..oOkdl.'0k.   cKO.     Resolution: 1920x1080
  :KKKKKKKKKKKKKKKKK: kKx..od lKd   .OK:     DE: KDE 4.11.5
  dKKKKKKKKKKKOx0KKKd ;0KKKO, kKKc   dKd     WM: KWin
  dKKKKKKKKKKKK;.;oOKx,..'..;kKKK0.  dKd     WM Theme: Oxygen
  :KKKKKKKKKKKK0o;...;cdxxOK0Oxc,.  .0K:     GTK Theme: oxygen-gtk [GTK2]
   kKKKKKKKKKKKKKKK0xl;'......,cdo  lKk      Icon Theme: oxygen
   '0KKKKKKKKKKKKKKKKKKKKK00KKOo;  c00'      Font: Sans Serif
    .kKKKOxddxkOO00000Okxoc;'.   .dKk.       CPU: AMD FX-8120 Eight-Core @ 3.1GHz
      l0Ko.                    .c00l.        GPU: AMD Radeon HD 6900 Series
       .l0Kk:.              .;xK0l.          RAM: 2517MB / 7981MB
          ,lkK0xl:;,,,,;:ldO0kl,            
              .':ldxkkkkxdl:'.  
Using the github version of SFML.

Now, I thought the increase was weird in itself, and not only because I don't quite know how to identify what the actual problem is, but I really thought a lib as established as SFML shouldn't have those kinds of issues (not bashing, just being honest.)

But what's even more weird to me is that the problem seems to be dependent on the resolution of the window, and some other factors. Here are some samples I noted from trying different resolutions:

150x150: 14.9mb memory usage, no noticeable increase.
320x240: Steady memory increase by 10mb every second.
640x480: Same as 320x240.
1600x900: 5mb per second increase.
1920x1080: This is equivalent to `fullscreen windowed mode` for me. Curiously, this shows a 3mb per second increase, but if I grab and move the window so that KDE automatically resizes it to ~1280x680, then the memory stops increasing and stays at whatever it was before I moved it. Manually setting the resolution to that value results in a 7mb per second increase.

If I limit the fps using RenderWindow::setFramerateLimit() then the increase is slowed down in proportion to the rate.

So I guess my questions are: Is this a known problem? Is the problem in my code, rather than a bug in SFML? Problem is in my system? Are there any workarounds to prevent this? Can you explain what is causing the leak? Why do the amounts vary depending on window resolution?

I appreciate any information or advice, thank you.

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Basic window memory issue
« Reply #1 on: May 28, 2014, 01:42:35 am »
Does this happen with a normal loop where you do clear()/draw()/display() and no raw OpenGL?  Using display() without clear() is definitely not right.

Mörkö

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
Re: Basic window memory issue
« Reply #2 on: May 28, 2014, 01:52:37 am »
Does this happen with a normal loop where you do clear()/draw()/display() and no raw OpenGL?  Using display() without clear() is definitely not right.

Yeah it does. RenderWindow::clear() seems to implement glClear() under the hood anyway, so I didn't think there would be any practical difference in the code by calling opengl directly, even if I'm mistaken, there seems to be no change in the result / problem.
« Last Edit: May 28, 2014, 01:55:03 am by Senap »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
AW: Basic window memory issue
« Reply #3 on: May 28, 2014, 02:01:51 am »
The more important questions are: How do you track the "leak"? And what is your graphics driver?

Leaking drivers are nothing new.

Using the github version of SFML.

I really thought a lib as established as SFML shouldn't have those kinds of issues (not bashing, just being honest.)
Don't forget the Git version is always something in development. So if you use the latest commit, then you should never be surprise if something doesn't work/is bugged. ;)
« Last Edit: May 28, 2014, 02:06:11 am by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Mörkö

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
Re: AW: Basic window memory issue
« Reply #4 on: May 28, 2014, 02:17:37 am »
The more important questions are: How do you track the "leak"? And what is your graphics driver?

Leaking drivers are nothing new.
Right.

I am tracking the memory usage by nothing more scientific than launching the program and checking my system monitor.

I'm using the proprietary FGLRX drivers.

Quote from: eXpl0it3r
Don't forget the Git version is always something in development. So if you use the latest commit, then you should never be surprise if something doesn't work/is bugged. ;)

Of course. I am just probing for info anyway.