Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
MervBot Memory-Leak Checking
Goto page 1, 2  Next
 
Post new topic   Reply to topic Printable version
 View previous topic  i need a scoring bot <3 Post :: Post LVZ toggling with mervbot  View next topic  
Author Message
CypherJF
I gargle nitroglycerin


Gender:Gender:Male
Joined: Aug 14 2003
Posts: 2582
Location: USA
Offline

PostPosted: Fri May 27, 2005 6:58 pm    Post subject: MervBot Memory-Leak Checking Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List
Solo Ace
Yeah, I'm in touch with reality...we correspond from time to time.


Age:37
Gender:Gender:Male
Joined: Feb 06 2004
Posts: 2583
Location: The Netherlands
Offline

PostPosted: Fri May 27, 2005 7:24 pm    Post subject: Reply to topic Reply with quote

Try using this (this code came straight from MSDN Library), it works fine for me heh.

Code: Show/Hide
// 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
View users profile Send private message Add User to Ignore List
CypherJF
I gargle nitroglycerin


Gender:Gender:Male
Joined: Aug 14 2003
Posts: 2582
Location: USA
Offline

PostPosted: Fri May 27, 2005 7:57 pm    Post subject: Reply to topic Reply with quote

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.


icon_confused.gif
Back to top
View users profile Send private message Add User to Ignore List
CypherJF
I gargle nitroglycerin


Gender:Gender:Male
Joined: Aug 14 2003
Posts: 2582
Location: USA
Offline

PostPosted: Fri May 27, 2005 9:14 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List
Cyan~Fire
I'll count you!
I'll count you!


Age:37
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Sat May 28, 2005 4:07 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List Visit posters website
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Sat May 28, 2005 4:16 pm    Post subject: Reply to topic Reply with quote

Not so. icon_smile.gif
_________________
4,691 irradiated haggis!
Back to top
View users profile Send private message Add User to Ignore List
CypherJF
I gargle nitroglycerin


Gender:Gender:Male
Joined: Aug 14 2003
Posts: 2582
Location: USA
Offline

PostPosted: Sat May 28, 2005 7:31 pm    Post subject: Reply to topic Reply with quote

I take it that there is no possible way of figuring it out - without checking everything by hand then eh?
Back to top
View users profile Send private message Add User to Ignore List
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Sat May 28, 2005 7:47 pm    Post subject: Reply to topic Reply with quote

There are lots of ways. All the information you need is in your dump.
Back to top
View users profile Send private message Add User to Ignore List
CypherJF
I gargle nitroglycerin


Gender:Gender:Male
Joined: Aug 14 2003
Posts: 2582
Location: USA
Offline

PostPosted: Sat May 28, 2005 8:37 pm    Post subject: Reply to topic Reply with quote

Way to be cryptic Mr Ekted - care to elaborate on HOW I could go about doing this? icon_smile.gif *continues to read on the Heap State Reporting Functions/Info on MSDN*
Back to top
View users profile Send private message Add User to Ignore List
Solo Ace
Yeah, I'm in touch with reality...we correspond from time to time.


Age:37
Gender:Gender:Male
Joined: Feb 06 2004
Posts: 2583
Location: The Netherlands
Offline

PostPosted: Sat May 28, 2005 8:46 pm    Post subject: Reply to topic Reply with quote

Whenever you allocated a variable you should let it output some information about the allocation.

Use this macro every time after allocation.
Code: Show/Hide
#define DEBUG_NEW(x) printf("allocation: %s %d 0x%p\n", __FILE__, __LINE__, x)


By doing this you can "trace" the leaking variable back by using the address the dump gave you.

I wouldn't know any other or better ways, so, Ekted, giving some more help would be appreciated. sa_tongue.gif
Back to top
View users profile Send private message Add User to Ignore List
CypherJF
I gargle nitroglycerin


Gender:Gender:Male
Joined: Aug 14 2003
Posts: 2582
Location: USA
Offline

PostPosted: Sat May 28, 2005 8:53 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Sat May 28, 2005 8:57 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List
CypherJF
I gargle nitroglycerin


Gender:Gender:Male
Joined: Aug 14 2003
Posts: 2582
Location: USA
Offline

PostPosted: Sat May 28, 2005 9:12 pm    Post subject: Reply to topic Reply with quote

Well, I did tested that macro that Solo gave - and the memory addresses provided do not match any of the allocations that I perform. I'm going to start assuming it has to do w/ a leak in the core?

the only structures that I 'new' up are
Code: Show/Hide
struct PlayerTag
{
   Player *p;
   char name[20];
   int index;
   int data;
};

struct OffenseTag
{
   Player *killer;
   Player *killed;
   int time;
   int id;
};


OffenseTag would be 12 byte's - right?

Quote:
Radon711 Got synchronization packet [1778400][1804605582]
Radon711 P:CypherJF> .load ctkwatch
allocation: C:\Projects\B45\cTKWatch\SPAWN.CPP 483 0x00C70EF0 bot = new botInfo(event.handle);
Radon711 Ext: DLL plugin connected.
allocation: C:\Projects\B45\cTKWatch\SPAWN.CPP 279 0x00C70E70 OffenseTag *ot = new OffenseTag();
Radon711 P:CypherJF> .tk 1
allocation: C:\Projects\B45\cTKWatch\SPAWN.CPP 534 0x00C70D40 Player *tag = new PlayerTag;
Radon711 A:Player warned
Radon711 P:CypherJF> .unload 0
Radon711 Ext: DLL plugin disconnected.
Detected memory leaks!
Dumping objects ->
{40} normal block at 0x00C70EB0, 12 bytes long.
Data: < > F0 0E C7 00 00 00 00 00 00 00 00 00
{37} normal block at 0x00C70EF0, 88 bytes long.
Data: < > 00 CD CD CD 00 00 00 00 00 00 00 00 00 00 00 00
Object dump complete.


Well found the 0x00C70EF0.

Thanks for the help.
Back to top
View users profile Send private message Add User to Ignore List
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Sat May 28, 2005 9:52 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List
CypherJF
I gargle nitroglycerin


Gender:Gender:Male
Joined: Aug 14 2003
Posts: 2582
Location: USA
Offline

PostPosted: Sat May 28, 2005 10:08 pm    Post subject: Reply to topic Reply with quote

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 icon_smile.gif).

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
View users profile Send private message Add User to Ignore List
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Sat May 28, 2005 11:12 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List
CypherJF
I gargle nitroglycerin


Gender:Gender:Male
Joined: Aug 14 2003
Posts: 2582
Location: USA
Offline

PostPosted: Sun May 29, 2005 2:10 am    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List
Bak
?ls -s
0 in


Age:26
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Sun May 29, 2005 4:39 am    Post subject: Reply to topic Reply with quote

I believe it's freed when the process terminates, because each process has it's own virtual memory that's 4 gigs big
_________________
SubSpace Discretion: A Third Generation SubSpace Client
Back to top
View users profile Send private message Add User to Ignore List AIM Address
CypherJF
I gargle nitroglycerin


Gender:Gender:Male
Joined: Aug 14 2003
Posts: 2582
Location: USA
Offline

PostPosted: Sun May 29, 2005 4:46 am    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List
Cyan~Fire
I'll count you!
I'll count you!


Age:37
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Sun May 29, 2005 10:38 am    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List Visit posters website
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Sun May 29, 2005 11:50 am    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List
Cyan~Fire
I'll count you!
I'll count you!


Age:37
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Sun May 29, 2005 9:23 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List Visit posters website
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Sun May 29, 2005 10:19 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List
CypherJF
I gargle nitroglycerin


Gender:Gender:Male
Joined: Aug 14 2003
Posts: 2582
Location: USA
Offline

PostPosted: Mon May 30, 2005 12:10 am    Post subject: Reply to topic Reply with quote

Got'cha, thanks everyone. icon_smile.gif
Back to top
View users profile Send private message Add User to Ignore List
Cyan~Fire
I'll count you!
I'll count you!


Age:37
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Mon May 30, 2005 1:03 pm    Post subject: Reply to topic Reply with quote

Ok. There are no leaks in the core. (Or at least none that the CRT detected.)
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> Bot Questions All times are GMT - 5 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 73 page(s) served in previous 5 minutes.

phpBB Created this page in 0.521710 seconds : 49 queries executed (90.5%): GZIP compression disabled