SFML community forums

Help => General => Topic started by: K-Bal on April 09, 2009, 02:35:19 pm

Title: High memory usage of SFML applications
Post by: K-Bal on April 09, 2009, 02:35:19 pm
Hey there,

I recognized that my SFML applications under Ubuntu use at least 40 megs of RAM. Even if I just open a RenderWindow and do nothing else but running the game loop.

I don't know if that is normal, but I guess that could be optimized.

I'm using 1.5 from the SVN.

Cheers,
Marius
Title: High memory usage of SFML applications
Post by: Astrof on April 09, 2009, 03:41:07 pm
SFML doesn't sleep unless you tell it to (or UseVerticalSync() or SetFramrateLimit() ) using sf::Sleep()
Title: High memory usage of SFML applications
Post by: Hiura on April 09, 2009, 04:12:31 pm
He's not speaking about CPU but RAM.  :wink:

That's odd, one of my application only need 5 MB of writable memory.
But its virtual memory is 34.3 MB.

Which kind of memory do you speak ?
Title: High memory usage of SFML applications
Post by: Laurent on April 09, 2009, 04:44:20 pm
Is it a fixed amount, or is it growing? Is it happening with other modules (network, audio)?
Title: High memory usage of SFML applications
Post by: K-Bal on April 10, 2009, 02:20:54 am
The amount of memory usage ist relatively constant at about 40 megs with a minimal application:

Creating a RenderWindow and running the game loop.

I didn't test this on Windows, I'm using Ubuntu 8.10.
Title: High memory usage of SFML applications
Post by: Laurent on April 10, 2009, 11:24:15 am
What about other modules?
Title: High memory usage of SFML applications
Post by: K-Bal on April 10, 2009, 02:40:11 pm
Quote from: "Laurent"
What about other modules?


I'll might check that out, if I have the time. At the moment I'm using my spare time for the SFML community contest of the german forum ;)

Next week, I'm back home, where I also have a Windows XP machine to test on.
Title: High memory usage of SFML applications
Post by: K-Bal on April 11, 2009, 11:10:48 am
The first thing I had time to check for was the difference between debug and release version.

The result: they both use about the same amount of RAM.
Title: High memory usage of SFML applications
Post by: Groogy on April 12, 2009, 01:24:00 pm
Sounds weird that it takes that much memory? It could be that SFML uses Xlib pixelbuffs(I think they were called that) too much?
Title: High memory usage of SFML applications
Post by: Laurent on April 12, 2009, 07:23:36 pm
SFML doesn't use pixelbuffs (I don't even know what it is).
Title: High memory usage of SFML applications
Post by: Groogy on April 12, 2009, 11:53:18 pm
I don't remember the correct name for the structure but it's Pixel... something. Anyway It's like Xlib's "Images" and is used to transfer image data from the client(application) to the server(display). Instead of sending the image all the time, it just passed the id of the image and the server knows what image it's talking about. Something like that.

You know the X-protocol was supposed to work over networks too :P


** EDIT **
It might be "Pixmaps". I searched quickly on the web and stumbled upon that name
Title: High memory usage of SFML applications
Post by: Laurent on April 12, 2009, 11:59:37 pm
Xlib is used only for windowing, SFML doesn't use it at all for graphics. Only OpenGL is used.
Title: High memory usage of SFML applications
Post by: Groogy on April 13, 2009, 12:02:27 am
Hmm ah then I'm lost. I haven't looked at glx at all so I don't know how it works.

Maybe is so that X server needs that much memory for an OpenGL Rendering context?
Title: High memory usage of SFML applications
Post by: JSLemming on April 13, 2009, 04:40:17 am
I'm running Ubuntu 8.10 also and all of the sample programs I've tried average about 9.5 MiB.

EDIT: I'm using 1.5 from the SVN as well.
Title: High memory usage of SFML applications
Post by: Hiura on April 13, 2009, 09:13:37 am
K-Bal, do you use option '-s' or '-Os' at compiling time ?
(I do.)
Title: High memory usage of SFML applications
Post by: K-Bal on April 13, 2009, 11:16:06 am
Quote from: "Hiura"
K-Bal, do you use option '-s' or '-Os' at compiling time ?
(I do.)


I don't know, I'll take a look this evening ;)
Title: High memory usage of SFML applications
Post by: K-Bal on April 14, 2009, 01:24:30 am
I used -s but no -Os, however, those compiler settings don't make a difference.
Title: High memory usage of SFML applications
Post by: Ceylo on April 14, 2009, 02:34:43 am
Of course they don't. It only changes the executable file size, not the memory usage.
Title: High memory usage of SFML applications
Post by: Hiura on April 14, 2009, 10:52:19 am
If you don't use -s your OS might load all debug symbols. Or  I'm wrong ?

Anyway it seems not being the point here.
Title: High memory usage of SFML applications
Post by: seoushi on April 15, 2009, 10:07:56 am
How are you getting the memory usage of the application? Linux and even Mac OS X for that matter don't always tell you the truth when it come to how much a program is actually using in memory. I've found that most of the time Linux will allocate a lot more memory than is needed for a program so the program can access more memory faster when needed.
Title: High memory usage of SFML applications
Post by: Tank on April 15, 2009, 01:44:39 pm
You also have to take memory caches into account.
Title: High memory usage of SFML applications
Post by: K-Bal on April 15, 2009, 10:47:52 pm
Yeah, might be. I just used the ubuntu system check tool.