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

Author Topic: Understanding memory usage of my application  (Read 4124 times)

0 Members and 1 Guest are viewing this topic.

Martin

  • Newbie
  • *
  • Posts: 10
    • View Profile
    • Weaving Stories
Understanding memory usage of my application
« on: November 13, 2015, 02:28:14 pm »
Hi,

I'm developing a game using SFML.NET. My application is compiled against .NET 4.5.1 using version 2.2 of the SFML.NET NuGet package.

The game uses a lot of high-resolution graphics, as well as some audio. This game is 2D, but it is high-fidelity. Recently memory usage has shot up from around 200MB to 750MB.

I'd like some advice on how to profile the memory usage of the application. I had expected that as I added more textures that these would be held in VRAM, and wouldn't significantly impact main memory usage, at least until I ran out of VRAM and OpenGL had to started swapping textures in and out more.

When I try profiling using Visual Studio 2015's built-in profiler, it only reports about 100MB of managed and heap memory usage. How can I get a more accurate breakdown of what is using up the memory?

Thanks for you time and your help.

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Understanding memory usage of my application
« Reply #1 on: November 13, 2015, 04:35:04 pm »
Are you using threads? Are you disposing SFML.Net objects when you are finished with them?

Quote
I had expected that as I added more textures that these would be held in VRAM, and wouldn't significantly impact main memory usage, at least until I ran out of VRAM and OpenGL had to started swapping textures in and out more.

How much VRAM does your GPU have and how many textures are you using?
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

Martin

  • Newbie
  • *
  • Posts: 10
    • View Profile
    • Weaving Stories
Re: Understanding memory usage of my application
« Reply #2 on: November 13, 2015, 04:45:30 pm »
I am disposing of Textures, SoundBuffers, and RenderTextures as I finish with them.

I use a thread to load Textures in without causing the main menu to hang. Once I am into the main game loop everything is single-threaded.

Looking into it I see I have misunderstood how much memory my graphics card has - it only has 128MB of dedicated memory, so the rest will be being stored in main memory.

So I would guess that the majority of my memory usage is textures. Is there any way of getting a breakdown of graphics memory usage? It would be really helpful for identifying exactly which game elements are taking up the majority of memory.

Martin

  • Newbie
  • *
  • Posts: 10
    • View Profile
    • Weaving Stories
Re: Understanding memory usage of my application
« Reply #3 on: November 13, 2015, 04:54:49 pm »
Ah, part of my confusion stems from the fact that my development machine has two graphics cards: An integrated Intel one, and a more powerful NVidia one. The NVidia graphics card has 2GB of dedicated memory - that's more like what I remembered!

So I need to confirm whether or not SFML is using the more powerful graphics card. If it is the question remains: Why is all this main memory being used? If it is not, then I need to figure out how to make sure I use the more powerful card.

Either way, I'd still really appreciate any advice on profiling graphics memory usage.

Thanks for the help so far!

Martin

  • Newbie
  • *
  • Posts: 10
    • View Profile
    • Weaving Stories
Re: Understanding memory usage of my application
« Reply #4 on: November 13, 2015, 05:02:44 pm »
Okay, I managed to make my game run on the high-performance card, and now main memory usage is down to 175MB - much more what I expected! Sorry for the multiple posts. So now my question is just: How can I profile the graphics memory usage?

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Understanding memory usage of my application
« Reply #5 on: November 13, 2015, 05:40:06 pm »
There is multiple OpenGL profilers available, one that I have found to work well in the past (even with SFML.Net) was gDEBugger. However any OpenGL profiler should work fine with SFML.
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Understanding memory usage of my application
« Reply #6 on: November 13, 2015, 07:52:06 pm »
Intel VTune can show you a lot of memory related info.
See also this: http://blogs.msdn.com/b/vcblog/archive/2015/10/21/memory-profiling-in-visual-c-2015.aspx

AlexAUT

  • Sr. Member
  • ****
  • Posts: 396
    • View Profile
Re: Understanding memory usage of my application
« Reply #7 on: November 14, 2015, 01:11:58 pm »
When you have an AMD card i can recommend CodeXL, when you have an NVIDIA card I can recommend NVIDIA Nsight.

Both tools allow you to pause the program and have a look at every texture/buffer/shader/etc. on the GPU, and the memory usage.


AlexAUT

Martin

  • Newbie
  • *
  • Posts: 10
    • View Profile
    • Weaving Stories
Re: Understanding memory usage of my application
« Reply #8 on: November 14, 2015, 01:56:20 pm »
Hi! Thanks for all the suggestions. It will take me a while to give them a go. I will do and I'll get back with my findings.