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

Author Topic: Trouble with memory usage (starting with maximally simple apps)  (Read 370 times)

0 Members and 1 Guest are viewing this topic.

Polestar

  • Guest
Running Windows 10. Compiling with Visual Studio 2022. Building with SFML 2.6, official VS17 builds (https://www.sfml-dev.org/files/SFML-2.6.0-windows-vc17-32-bit.zip, etc.).

Problem: SFML applications are using a fair amount of memory, both upfront and as they grow in complexity. Yes, I know  that this problem has been reported before.

Compiler options (release builds): SFML_STATIC, full optimization (speed). Use the statically-linked, release versions of the libraries (and their dependences).
Linker options (debug builds): dynamic linking, no optimization. Use the provided DLLs with debugging data.

Release build (Win32), using the window display code at www.sfml-dev.org/tutorials/2.6/window-window.php, "Bringing the Window to Life". No other changes. Uses 72 MB.
Repeat with debug build. Repeat with x64 release and debug. Repeat, using the GCC 13.1.0 MinGW compiled versions of the SFML 2.6 libraries. Uses slightly more (<10 MB) in some cases, as expected, but never less than the VS17 32-bit release build.

Duplicate the line "sf::RenderWindow window(sf::VideoMode(800, 600), "My window");" to make four separate windows. Memory usage goes up to 155 MB.

Code follows:

#include <SFML/Graphics.hpp>

int main()
{
   sf::RenderWindow window(sf::VideoMode(800, 600), "My window");

   sf::RenderWindow window2(sf::VideoMode(800, 600), "My second window");

   sf::RenderWindow window3(sf::VideoMode(800, 600), "My third window");

   sf::RenderWindow window4(sf::VideoMode(800, 600), "My fourth window");

   // run the program as long as the window is open
   while (window.isOpen())
   {
      // check all the window&#39;s events that were triggered since the last iteration of the loop
      sf::Event event;
      while (window.pollEvent(event))
      {
         // "close requested" event: we close the window
         if (event.type == sf::Event::Closed)
            window.close();
      }

      sf::sleep(sf::milliseconds(100));
   }

   return 0;
}


Remove the source files. Add the source and header files for the Island app in the examples folder. Re-compile from scratch, using the 32-bit release version of the official MSVC17 libraries. Copy the "resources" folder. Fire up the executable. 209 MB of memory used when generating the terrain. 154 MB used when idle.


Imma gonna level with you. I got feelings about this. I got feeling so hard I need to break out the Newspeak with you all and say that this is DoublePlusUnGood.

Hapax

  • Hero Member
  • *****
  • Posts: 3351
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Trouble with memory usage (starting with maximally simple apps)
« Reply #1 on: July 31, 2023, 10:24:20 pm »
Don't forget that all 4 windows need their events checked.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Thrasher

  • SFML Team
  • Jr. Member
  • *****
  • Posts: 53
    • View Profile
Re: Trouble with memory usage (starting with maximally simple apps)
« Reply #2 on: August 01, 2023, 05:36:28 am »
What level of memory usage were you expecting to see? Have you compared this to other libraries to like SDL to see if memory usage is dramatically different?

 

anything