Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
auth_update crash
Dec 23, 2017, 10:15 pm
By Remcon
check_tumble
Dec 18, 2017, 7:21 pm
By Remcon
parse description bug
Dec 15, 2017, 10:08 pm
By Remcon
Couple bugs
Dec 12, 2017, 5:42 pm
By Remcon
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
LoP 1.46
Author: Remcon
Submitted by: Remcon
LOP 1.45
Author: Remcon
Submitted by: Remcon
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Users Online
CommonCrawl, Yahoo!, DotBot

Members: 0
Guests: 8
Stats
Files
Topics
Posts
Members
Newest Member
478
3,708
19,242
612
Jacki72H
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » General » General Discussions » Valgrind
Forum Rules | Mark all | Recent Posts

Valgrind
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Sep 5, 2005, 8:34 am
Go to the top of the page
Go to the bottom of the page

Noplex
Apprentice
GroupMembers
Posts62
JoinedAug 30, 2005

Does Valgrind work on Windows (and with C++?)? I've got a rather large memory leak that I need to figure out, and it only seems to happen when someone is connecting from the outside (i.e. not local network).
       
Post is unread #2 Sep 5, 2005, 9:21 am
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,868
JoinedJul 26, 2005

dont know, but id say you should put it on a linux server that has valgrind and find the leaks that way :) then you can put it back on your windows :)
       
Post is unread #3 Sep 5, 2005, 10:36 am
Go to the top of the page
Go to the bottom of the page

Noplex
Apprentice
GroupMembers
Posts62
JoinedAug 30, 2005

I don't have access to a unix box right now.
       
Post is unread #4 Sep 5, 2005, 11:00 am
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
JoinedJan 1, 2002

Valgrind doesn't have a version that runs under Windows, but it does work just fine with C++.
       
Post is unread #5 Sep 5, 2005, 11:20 am   Last edited Sep 5, 2005, 11:21 am by Noplex
Go to the top of the page
Go to the bottom of the page

Noplex
Apprentice
GroupMembers
Posts62
JoinedAug 30, 2005

Okay well I fixed my code up, the problem was mixed between GMUD and stupid mistake by myself. I'm posting on here because I know I've rolled out this code to a few people before, especially when I was building my IMC2 client, and its prone to the error as well. So here is the snip:
Before the fix applied, at the bottom:
// <summary> Read in a whole line, parse out a single word (depending on quotes and such) and
//	then throw back the remaining onto the input stream (via the above method) </summary>
string CSystem::ReadWord(string& line, char delim, bool upper)
{
	if( line.empty() )
	{
		engine()->log()->write("NULL line passed through readword",0);
		return "";
	}

	string::size_type tail = line.find( delim );
	if( tail==string::npos )
	{
		tail = line.find('\n');
		if( tail==string::npos )
		{
			tail = line.find('\r');
			if( tail==string::npos )
				tail = line.length();
		}
	}

	// added the sequence to check for quotes; taken from my IMC2 network client
	// that should be downloadable from flipsidesoftware.com*
	string::size_type quote = line.find('"');
	if( ( quote > 0 ) && ( quote < tail ) && (line[ quote-1 ] != '\\') )
	{
		line = line.substr( quote+1, line.length() );
		while( (quote = line.find('"', tail+1)) != string::npos)
		{
			tail = quote;
			if( (quote > 0) && ( line[ quote-1 ] == '\\'))
				continue;
			else
				break;
		}
	}

	string word = line.substr( 0, tail );
	if( tail+1 < line.length() )
		line = line.substr( tail+1, line.length() );

	if( upper )
		word[0] = UPPER( word[0] );
	return word;
}


The bottom segment, with the fix
	string word = line.substr( 0, tail );
	if( tail+1 < line.length() )
		line = line.substr( tail+1, line.length() );
	else
		line.clear();

	if( upper )
		word[0] = UPPER( word[0] );
	return word;
}


And as you can imagine, without that nice little else if clause there, we have a big, big, big problem. It created a huge circular buffer that just kept on dumping memory into my string inbuffer.

I think I may have given Samson code similar to this awhile ago when he was restructuring something on the IMC2/I3 client. You probably have caught the bug before I did. Be careful everyone :D, mistakes like these could very well take down a server (it ate up 1.5 gigs of memory in no time on this machine).
       
Pages:<< prev 1 next >>