Jump to content
  • Advertisement
Sign in to follow this  

Memory leaks and threads

This topic is 3411 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

I've been working with threads for quite a while now, trying to get the hang of them. I always add the following to a project while programming it:
//in the main.cpp file
#include <stdlib.h>
#include <crtdbg.h>

//and this as the first function called

I was wondering if this also detects memory leaks that will appear in threads, or do I need to do something more to detect memory leaks in threads? Thanks in advance, Max Henger

Share this post

Link to post
Share on other sites
After trying it:
It is enough to call _CrtSetDbgFlag in the main thread.
I created my thread with _beginthreadex and allocated a int in it, but never deleted it (i assume this is a memory leak ;) ) and when it was terminated, Visual Studio wrote something like this:

Detected memory leaks!
Dumping objects ->
{338} normal block at 0x00000000003EDC90, 4 bytes long.
Data: < > CD CD CD CD
Object dump complete.

Hope this helps

Share this post

Link to post
Share on other sites
how stupid of me! most of the time i create simple tests like these myself. i don't know why i didn't this time. thank you for checking this out for me!

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!