#### Archived

This topic is now archived and is closed to further replies.

# Bizzare memory problem..

This topic is 5422 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I''m not quite sure why this is happening, infact i''ve never seen this happen before with stuff i''ve done, but for some reason while trying to push_back() a class onto an std::list its mucking up a vector<char> i''ve got stored in the class. Relivent bits of code are :
class connectiondetails
{
public:
SOCKET socket;	// socket to send on

std::vector<char> data;	// data to send

connectiondetails(){};
connectiondetails(const connectiondetails & cd)
{
socket = cd.socket;
data.reserve(cd.data.size());
data.assign(cd.data.begin(),cd.data.end());
sender = cd.sender;
}
};

{
m_sendqueue.push_back(details);
}

Now, i''ve traced it in debug mode, and stepping through the copy-constructor, it seems to setup the data vector correctly, however I tend traced into the STL itself and the point it seems to go wrong is indicated here :
_Nodeptr _Buynode(_Nodeptr _Next,
_Nodeptr _Prev, const _Ty& _Val)
{	// allocate a node and set links and value

_Nodeptr _Pnode = this->_Alnod.allocate(1);
_TRY_BEGIN
new ((void *)_Pnode) _Node(_Next, _Prev, _Val);  // after here the data is wrong, just shows ''bad_ptr'' in the debug window

_CATCH_ALL
this->_Alnod.deallocate(_Pnode, 1);
_RERAISE;
_CATCH_END
return (_Pnode);
}

If anyone has any ideas why this could be happening, and how i might be able to fix it i''d appricate it For the record i''m using VS.Net03 on WinXP I''ve been pushing stuff back onto lists in other parts of this program with no trouble. Below is the code which gets me to the point above
void SendInitalData()
{
std::vector<char> query;	// query to send

std::string request("\\status");
query.reserve(request.length()+1);
//			strcpy(query[0],request.c_str());	// copy into the query buffer

query.assign(request.size(),*(request.c_str()));
strcpy(&query[0],request.c_str());
//			if(!m_connection.expired())

{
boost::shared_ptr<Networking::ConnectionObject> connection = m_connection.lock();
final = false;
}
}

// allows data to be sent out via its socket

{
connectiondetails details;
details.data.reserve(data.size());
details.data.assign(data.begin(),data.end());
//details.data = *data;

details.socket = socket;

}


##### Share on other sites
Have you recently added any members to your class? If so, make sure that you recompile all dependant code. If some code dealing with your class thinks it is a different size than it actually is, then the wrong variable can easily be written to. This is the first thing that comes to mind with the problem you described.

______________________________________________________________
The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ
MySite
______________________________________________________________

[edited by - Thunder_Hawk on December 13, 2003 11:27:26 PM]

##### Share on other sites
For my experience with VS.NET, I would actually recommend simply recompiling everything, as in deleting the whole "Debug" or "Release" folder and start from scratch.

VS.NET tries to be lazy by doing an incremental compile and making only the needed changes to object files, then re-linking them together into the executable. But I''ve noticed that it doesn''t always work. I''m not sure of the exact fail conditions, but I''ve always made it a point to do full rebuilds when working with Microsoft compilers. It''s just safer.

"Remember: Silly is a state of Mind, Stupid is a way of Life." -- Dave Butler

##### Share on other sites
quote:
Original post by Indigo Darkwolf
For my experience with VS.NET, I would actually recommend simply recompiling everything, as in deleting the whole "Debug" or "Release" folder and start from scratch.

VS.NET tries to be lazy by doing an incremental compile and making only the needed changes to object files, then re-linking them together into the executable. But I''ve noticed that it doesn''t always work. I''m not sure of the exact fail conditions, but I''ve always made it a point to do full rebuilds when working with Microsoft compilers. It''s just safer.

"Remember: Silly is a state of Mind, Stupid is a way of Life." -- Dave Butler

Same with me. I always rebuild my project instead of compiling it.

##### Share on other sites
yeah, i''ve just forced a completely clean recompile and its working now.
meh, should have thought of that myself, its been a long few days working on this however

Now, i just have to work out why my microthreads are blowing up :|

1. 1
2. 2
3. 3
Rutin
22
4. 4
5. 5

• 13
• 19
• 14
• 9
• 9
• ### Forum Statistics

• Total Topics
632930
• Total Posts
3009290
• ### Who's Online (See full list)

There are no registered users currently online

×

## Important Information

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!