|
-
Jul 3rd, 2001, 10:21 AM
#1
Thread Starter
Frenzied Member
Memory Leaks
After my program is done running in debug mode, the debug window shows 2 threads that have exited with -1 (0xFFFFFFFF). I believe that means that they have memory leaked. Anyone know how to track down those nasty things?
MSVS 6, .NET & .NET 2003 Pro
I HATE MSDN with .NET & .NET 2003!!!
Check out my sites:
http://www.filthyhands.com
http://www.techno-coding.com

-
Jul 3rd, 2001, 11:01 AM
#2
Monday Morning Lunatic
One method I use is to do a search to count all the occurences of new, and the occurences of delete, and make sure they're the same number.
However, I don't think a thread returning -1 means there's a memory leak - I think it signifies some other kind of failure.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Jul 3rd, 2001, 11:07 AM
#3
Thread Starter
Frenzied Member
Thats the first thing I checked.
I used the C++ debug routines to check on memory leaks and it did not seem to trigger, so maybe the -1 is not a leak.
MSVS 6, .NET & .NET 2003 Pro
I HATE MSDN with .NET & .NET 2003!!!
Check out my sites:
http://www.filthyhands.com
http://www.techno-coding.com

-
Jul 3rd, 2001, 11:10 AM
#4
Monday Morning Lunatic
www.flipcode.com has a good thread on memory leak detection.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Jul 3rd, 2001, 11:29 AM
#5
Thread Starter
Frenzied Member
I found:
PHP Code:
#ifndef NDEBUG
int flag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); // Get current flag
flag |= _CRTDBG_LEAK_CHECK_DF; // Turn on leak-checking bit
_CrtSetDbgFlag(flag); // Set flag to the new value
#endif
and added it to my WinMain and it works when I turn off my delete[]. But it did not detect any leaks on my program regularly, so there must not be a problem....I hope.
MSVS 6, .NET & .NET 2003 Pro
I HATE MSDN with .NET & .NET 2003!!!
Check out my sites:
http://www.filthyhands.com
http://www.techno-coding.com

-
Jul 3rd, 2001, 11:31 AM
#6
Monday Morning Lunatic
We all hope 
I hate memory leaks...they're so annoying - especially the delete rather than delete[] kind.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Jul 3rd, 2001, 11:55 AM
#7
Thread Starter
Frenzied Member
Ok this is still bugging me
a) How can I tell what the threads are assigned to?
b) Can you quickly give me the code to write to a simple text file I dont want to have to go look it up.
MSVS 6, .NET & .NET 2003 Pro
I HATE MSDN with .NET & .NET 2003!!!
Check out my sites:
http://www.filthyhands.com
http://www.techno-coding.com

-
Jul 3rd, 2001, 12:07 PM
#8
Monday Morning Lunatic
Code:
#include <fstream>
using namespace std;
void somecode() {
ofstream OutFile("filename.ext");
if(OutFile.fail() // Didn't work
return;
OutFile << "Hello: " << 5 << '6' << endl;
}
The files are automatically closed when the object goes out of scope.
I don't get what you mean with (a)
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Jul 3rd, 2001, 12:14 PM
#9
Thread Starter
Frenzied Member
a) I mean it say like thread 0xFFF57315 exited with code -1. How do I know what thread 0xFFF57315 was?
b)Thanks
MSVS 6, .NET & .NET 2003 Pro
I HATE MSDN with .NET & .NET 2003!!!
Check out my sites:
http://www.filthyhands.com
http://www.techno-coding.com

-
Jul 3rd, 2001, 12:20 PM
#10
Monday Morning Lunatic
It might be the thread ID or thread handle (the value returned from CreateThread).
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|