Jump to content
  • Advertisement
Sign in to follow this  
Alundra

Memory Leaks on shutdown of QT application

This topic is 1078 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,

I have D3D11 memory leaks on the shutdown of my QT application but on the build outside editor no leaks found.

The render system is actually a static variable so it's destroyed at the end of the application.

What is the possible cause of this memory leaks ?

Thanks

Edited by Alundra

Share this post


Link to post
Share on other sites
Advertisement

Hi! If you have memory leaks that you are concerned about (e.g. that actually leak memory in response to application activities besides simply exiting the application), then you will need to clear away the application exit memory leaks as well so that you can more clearly see the other memory leaks to remove them.

 

At the basic level, you have allocated memory and have not freed it before your application exits. This can also stem from incrementing a ref count to a COM object (often unknowingly through an API call) and thus preventing the program from freeing the memory for the COM object. You could also be re-allocating memory to a pointer without first freeing it (this would be a dangerous heap leak).

 

A first suggestion is to enable debug heap at the beginning of your program and then run the application in Visual Studio in debug mode and scrub through the unfreed allocations.

 

if the below doesn't work, try gflags from application verifier and enable their debug heap, but I have run out of memory on moderately sized and larger programs doing that (debug heaps are expensive on memory budgets!) Good luck, please post more information for us to help you!!!

    // Enable run-time memory check for debug builds.
#if defined(DEBUG) | defined(_DEBUG)
    _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
#endif
Edited by Steve_Segreto

Share this post


Link to post
Share on other sites

I have logged one message on the start of the shutdown function and it's correctly called, meaning the shutdown function is called.

here the code I use to call it :

namespace
{
  void AboutToQuit()
  {
    CEditor::Shutdown();
  }

} // namespace

int main( int argc, char* argv[] )
{
  // Create the application.
  QApplication Application( argc, argv );
  QObject::connect( &Application, &QApplication::aboutToQuit, AboutToQuit );
  ...
}

The editor shutdown call the same engine shutdown code than the build outside the editor.

Edited by Alundra

Share this post


Link to post
Share on other sites

That's the funny thing about chasing heap leaks, when you examine the code everything looks like its being cleaned up correctly. You need to enlist the help of tools like the CRT debug heap or gflags debug heap to help you understand which allocations are being made without being freed, because this can provoke new thought and cause you to see what you are missing. I just caught a heap leak in my own source code last night that resulted from some scene graph nodes not being parented as I would have expected so even though the de-allocation code was rock solid and correct, there was still a heap leak because for a certain class of model a certain group of scene graph nodes were created as orphans without parents and thus a top-down de-allocation algorithm couldn't find them.

Share this post


Link to post
Share on other sites

I found exactly where the leaks happen, it's when the render window is resized, maybe because I don't clean up correctly everywhere the set of variables of shaders and because of that the release count never go down to 0, if it's the reason, the leak then has nothing to do with Qt, it's an engine issue.

Edited by Alundra

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!