C ++ / opengl application runs smoothly with a debugger application

Have you encountered a situation where a C ++ opengl application is faster and smoother when executed from a visual studio? When it is executed normally, without a debugger, I get a lower frame rate, 50 instead of 80, and a strange lag, where fps goes down to 25 frames / sec every 20-30 frames. Is there any way to fix this?

Edit : We also use quite a few display lists (created using glNewList). And increasing the number of displayed lists seems to increase the lag.

Edit : The problem appears to be caused by page errors. Setting up a configuration workflow using SetProcessWorkingSetSizeEx () does not help.

Edit : With some large models, the problem is easy to spot using the procexp-utility GPU utility. Memory usage is very unstable when there are many glCallList calls per frame. No new geometry is added, textures are not loaded, but gpu's memory allocation is + -20 MB. After a while, it gets worse and can allocate something like 150 MB at a time.

+6
source share
3 answers

I believe that what you see is a debugger that blocks some pages so that they cannot be exchanged so that they are immediately accessible to the debugger. This leads to some warnings for the OS during process switching and is generally not recommended.

You probably won't like it when I say this, but there is no good way to fix it, even if you do.

Use VBOs or at least vertex arrays, you can expect that the driver will be much better optimized (let it look - the display lists are outdated). Display lists can be easily wrapped to generate vertex buffers, so you just need to slightly modify the old code. In addition, you can use "contactless graphics", which was designed to prevent page errors in the driver (GL_EXT_direct_state_access).

+3
source

Do you have an nVidia graphics card? When connecting to the nVidia debugger, OpenGL uses a different implementation. For me, the version without a debugger passes memory at speeds up to 1 MB / s in certain situations when I draw to the front buffer and do not call glClear for each frame. The debugger version is absolutely beautiful.

I have no idea why he should allocate and (sometimes) free up so much memory for a scene that does not change.

And I do not use display lists.

+2
source

This is probably the priority of a thread or process. Visual Studio can start your process with a slightly higher priority to ensure that the debugger is responsive. Try using SetPriorityClass () in your application code:

SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS); 

The “above normal” class simply pushes it ahead of everything else with the “normal” class. As the documentation says, do not click on super-high priority or you can ruin the system scheduler.

In an application running at 60 frames per second, you only get 16 ms to draw a frame (less than 80 frames per second!) - if you need more time, you will take a frame that can cause a slight drop in frame rate. If your application has the same priority as other applications, most likely another application may temporarily steal the processor for some task, and you will lose several frames or at least skip the window with 16 ms for the current frame. The idea of ​​raising priority slightly means that Windows returns to your application more often, so it doesn't drop as many frames.

0
source

Source: https://habr.com/ru/post/905949/


All Articles