Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++/opengl application running smoother with debugger attached

Tags:

c++

opengl

Have you experienced a situation, where C++ opengl application is running faster and smoother when executed from visual studio? When executed normally, without debugger, I get lower framerate, 50 instead of 80, and a strange lagging, where fps is diving to about 25 frames/sec every 20-30th frame. Is there a way to fix this?

Edit: Also we are using quite many display lists (created with glNewList). And increasing the number of display lists seem to increase lagging.

Edit: The problem seems to be caused by page faults. Adjusting process working set with SetProcessWorkingSetSizeEx() doesn't help.

Edit: With some large models the problem is easy to spot with procexp-utility's GPU-memory usage. Memory usage is very unstable when there are many glCallList-calls per frame. No new geometry is added, no textures loaded, but gpu-memory-allocation fluctuates +-20 Mbytes. After a while it becomes even worse, and may allocate something like 150Mb in one go.

like image 844
AareP Avatar asked Jan 13 '12 22:01

AareP


2 Answers

I believe that what you are seeing is the debugger locking some pages so they couldn't be swapped to be immediately accessible to the debugger. This brings some caveats for OS at the time of process switching and is, in general, not reccommended.

You will probably not like to hear me saying this, but there is no good way to fix this, even if you do.

Use VBOs, or at least vertex arrays, those can be expected to be optimized much better in the driver (let's face it - display lists are getting obsolete). Display lists can be easily wrapped to generate vertex buffers so only a little of the old code needs to be modified. Also, you can use "bindless graphics" which was designed to avoid page faults in the driver (GL_EXT_direct_state_access).

like image 106
the swine Avatar answered Sep 29 '22 20:09

the swine


Do you have an nVidia graphics card by any chance? nVidia OpenGL appears to use a different implementation when attached to the debugger. For me, the non-debugger version is leaking memory at up to 1 MB/sec in certain situations where I draw to the front buffer and don't call glClear each frame. The debugger version is absolutely fine.

I have no idea why it needs to allocate and (sometimes) deallocate so much memory for a scene that's not changing.

And I'm not using display lists.

like image 26
RichW Avatar answered Sep 29 '22 21:09

RichW