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

Author Topic: Main Memory  (Read 1231 times)

0 Members and 1 Guest are viewing this topic.

Reborn

  • Newbie
  • *
  • Posts: 25
    • View Profile
Main Memory
« on: April 05, 2014, 06:55:15 pm »
Hello,
i just load 1 Pic with 7,87 kb into the RAM by using the Function m_textureField.loadFromFile(filePath); and my main memory goes up from 2,5 to 20 Mb, is this normaly possible? When i load 200 pics more with the same size the main memory goes up to 50 MB.

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Main Memory
« Reply #1 on: April 05, 2014, 06:58:49 pm »
Exactely how do you measure this memory consumption?

Be aware that many image formats are compressed, so size on disk will be smaller than when loaded (and decompressed) in memory.
Also, loading the image could trigger loading of library code.

Reborn

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: Main Memory
« Reply #2 on: April 05, 2014, 07:17:13 pm »
GetProcessMemoryInfo().
When i call window.update() in a loop, the ram increase until it reach 10Mb more.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10826
    • View Profile
    • development blog
    • Email
Re: Main Memory
« Reply #3 on: April 06, 2014, 04:34:56 pm »
Why do people always try to monitor memory usage if they've no idea, neither abstract nor practical, how memory gets managed? ;)

If something makes one memory allocation chances are probably around 90+% that it will do another allocation at one point and thus if you tell the OS to allocate some memory, it will provide you with more memory than actually needed, while still being able to take it away again, if memory is running out.
GetProcessMemoryInfo() probably provides about the same information as the task manager and thus is not a good way to track memory usage.

Also as Jesper mentioned, image files on the harddisk are usually smaller, since you use a compression algorithm, but when loaded in memory every single pixel is accounted for.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/