Author |
Message |
CypherJF I gargle nitroglycerin

Gender: Joined: Aug 14 2003 Posts: 2582 Location: USA Offline
|
Posted: Fri May 27, 2005 6:58 pm Post subject: MervBot Memory-Leak Checking |
 |
|
|
|
Using MervBot b45/b46 - is there any way to come up w/ an effective way of determining that there are no memory leaks occuring within a specific plugin? I'm pretty confident I have deleting allocated memory, but would like to put my mind to ease over it. MMaverick said there used to be a way? Thanks in advance. _________________ Performance is often the art of cheating carefully. - James Gosling |
|
Back to top |
|
 |
Solo Ace Yeah, I'm in touch with reality...we correspond from time to time.

Age:37 Gender: Joined: Feb 06 2004 Posts: 2583 Location: The Netherlands Offline
|
Posted: Fri May 27, 2005 7:24 pm Post subject: |
 |
|
|
|
Try using this (this code came straight from MSDN Library), it works fine for me heh.
// Where your DLL is loaded, call these:
_CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE );
_CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDOUT );
_CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_FILE );
_CrtSetReportFile( _CRT_ERROR, _CRTDBG_FILE_STDOUT );
_CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE );
_CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDOUT );
// Then where you want to check for a memory leak, see if there are memory leaks and dump results into the console:
_CrtDumpMemoryLeaks( ); |
Taken from MSDN's _CrtDumpMemoryLeaks.
Hope that helps, good luck. |
|
Back to top |
|
 |
CypherJF I gargle nitroglycerin

Gender: Joined: Aug 14 2003 Posts: 2582 Location: USA Offline
|
Posted: Fri May 27, 2005 7:57 pm Post subject: |
 |
|
|
|
Thanks now to interpret the results:
Quote: | Radon711 Ext: DLL plugin disconnected.
Detected memory leaks!
Dumping objects ->
{38} normal block at 0x00E70050, 12 bytes long.
Data: < > F0 0E E7 00 00 00 00 00 00 00 00 00
{37} normal block at 0x00E70EF0, 88 bytes long.
Data: < > 00 CD CD CD 00 00 00 00 00 00 00 00 00 00 00 00
Object dump complete. |
 |
|
Back to top |
|
 |
CypherJF I gargle nitroglycerin

Gender: Joined: Aug 14 2003 Posts: 2582 Location: USA Offline
|
Posted: Fri May 27, 2005 9:14 pm Post subject: |
 |
|
|
|
Sorry for the double post, but when I did the MervCore - w/ debug mode - there were a ton of memory leak objects detected. :shrug: |
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Sat May 28, 2005 4:07 pm Post subject: |
 |
|
|
|
Look for anywhere where you could be allocating those sizes. That's really the only way to do it. _________________ This help is informational only. No representation is made or warranty given as to its content. User assumes all risk of use. Cyan~Fire assumes no responsibility for any loss or delay resulting from such use.
Wise men STILL seek Him. |
|
Back to top |
|
 |
Mr Ekted Movie Geek

Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: Sat May 28, 2005 4:16 pm Post subject: |
 |
|
|
|
Not so.  _________________ 4,691 irradiated haggis! |
|
Back to top |
|
 |
CypherJF I gargle nitroglycerin

Gender: Joined: Aug 14 2003 Posts: 2582 Location: USA Offline
|
Posted: Sat May 28, 2005 7:31 pm Post subject: |
 |
|
|
|
I take it that there is no possible way of figuring it out - without checking everything by hand then eh? |
|
Back to top |
|
 |
Mr Ekted Movie Geek

Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: Sat May 28, 2005 7:47 pm Post subject: |
 |
|
|
|
There are lots of ways. All the information you need is in your dump. |
|
Back to top |
|
 |
CypherJF I gargle nitroglycerin

Gender: Joined: Aug 14 2003 Posts: 2582 Location: USA Offline
|
Posted: Sat May 28, 2005 8:37 pm Post subject: |
 |
|
|
|
Way to be cryptic Mr Ekted - care to elaborate on HOW I could go about doing this? *continues to read on the Heap State Reporting Functions/Info on MSDN* |
|
Back to top |
|
 |
Solo Ace Yeah, I'm in touch with reality...we correspond from time to time.

Age:37 Gender: Joined: Feb 06 2004 Posts: 2583 Location: The Netherlands Offline
|
|
Back to top |
|
 |
CypherJF I gargle nitroglycerin

Gender: Joined: Aug 14 2003 Posts: 2582 Location: USA Offline
|
Posted: Sat May 28, 2005 8:53 pm Post subject: |
 |
|
|
|
Just some cliff-notes:
{#} - this allocation request number is enclosed in curly brackets (for example, “{36}”).
And -- New objects are filled with 0xCD when they are allocated.
msdn
msdn2 |
|
Back to top |
|
 |
Mr Ekted Movie Geek

Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: Sat May 28, 2005 8:57 pm Post subject: |
 |
|
|
|
1. You have the length and content of the leaked memory. So you are looking for allocations of 12 and 88 bytes. Find all your allocations and look at how big they are.
2. You have the contents. What structures that you allocate could contain the data "F0 0E E7 00" or "00 CD CD CD"?
3. You have the addresses. If you run the EXE under exactly the same circumstance with no random elements, all of the allocations will be the same addresses. |
|
Back to top |
|
 |
CypherJF I gargle nitroglycerin

Gender: Joined: Aug 14 2003 Posts: 2582 Location: USA Offline
|
|
Back to top |
|
 |
Mr Ekted Movie Geek

Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: Sat May 28, 2005 9:52 pm Post subject: |
 |
|
|
|
PlayerTag is 32. OffenseTag is 16.
I assumed you had run the core without your DLL first. If it's the core, you will get that same dump. |
|
Back to top |
|
 |
CypherJF I gargle nitroglycerin

Gender: Joined: Aug 14 2003 Posts: 2582 Location: USA Offline
|
Posted: Sat May 28, 2005 10:08 pm Post subject: |
 |
|
|
|
Ya, I didn't post that run of a clean core run w/o plugin. I was looking at the src code more closely the one offset is the
botInfo *bot;
...
bot = new botInfo(event.handle);
botlist.append(bot);
Anyways, the botlist is never cleared out or delete the dynamically allocated memory - Catid told me he had that intentionally in there because it was a fix to something, if he recalled correctly (I can see Ekted 'cringe' at that ).
So that's technically 1 allocation that isn't cleared which I could find - to find a fix - ... is another question. But thanks everyone for the help. |
|
Back to top |
|
 |
Mr Ekted Movie Geek

Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: Sat May 28, 2005 11:12 pm Post subject: |
 |
|
|
|
If it's always just the 2 blocks no matter how long you run, then you are fine. The process isn't leaking memory over time. |
|
Back to top |
|
 |
CypherJF I gargle nitroglycerin

Gender: Joined: Aug 14 2003 Posts: 2582 Location: USA Offline
|
Posted: Sun May 29, 2005 2:10 am Post subject: |
 |
|
|
|
But it is my understanding though that the dynamically non-released memory will never be allowed to be claimed by the heap manager until a system reboot - is that correct?
Like Catid said, it's fine if it leaks - but it's only bad if you're always unloading and reloading plugins...
But really, there should be no memory leaks in an application - if at all possible. |
|
Back to top |
|
 |
Bak ?ls -s 0 in

Age:26 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
|
Back to top |
|
 |
CypherJF I gargle nitroglycerin

Gender: Joined: Aug 14 2003 Posts: 2582 Location: USA Offline
|
Posted: Sun May 29, 2005 4:46 am Post subject: |
 |
|
|
|
I've read that before, but I wonder how that comes into play when my professors were teaching the class what I had mentioned in my other post. Was this the case for the older programs/OS'? |
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Sun May 29, 2005 10:38 am Post subject: |
 |
|
|
|
Windows is supposed to clean up every program's heap, but it doesn't always do the best job of it, which is why I always manually free everything. |
|
Back to top |
|
 |
Mr Ekted Movie Geek

Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: Sun May 29, 2005 11:50 am Post subject: |
 |
|
|
|
Everything specifically allocated on any heap is freed when the process is terminated. This is also true of window handles, resource handles (pens, brushes, fonts, etc), open files/pipes/mutexes/etc. The only thing I can see being an OS-level leak would be handles into driver objects with a bad driver (not cleaning up correctly), but the user-level has no control over this. |
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Sun May 29, 2005 9:23 pm Post subject: |
 |
|
|
|
Well, it's only one more line of code in your app, so I'd say it's a case when "better safe than sorry" is actually true. |
|
Back to top |
|
 |
Mr Ekted Movie Geek

Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: Sun May 29, 2005 10:19 pm Post subject: |
 |
|
|
|
I'm not saying "don't worry about freeing stuff." By all means write clean code. But if the leak is in the core, and you don't feel like debugging someone else's problem, AND it's not a recurrring leak, then it's not as a big a deal. |
|
Back to top |
|
 |
CypherJF I gargle nitroglycerin

Gender: Joined: Aug 14 2003 Posts: 2582 Location: USA Offline
|
Posted: Mon May 30, 2005 12:10 am Post subject: |
 |
|
|
|
Got'cha, thanks everyone.  |
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Mon May 30, 2005 1:03 pm Post subject: |
 |
|
|
|
Ok. There are no leaks in the core. (Or at least none that the CRT detected.) |
|
Back to top |
|
 |
|