Search

Memory leak with std::vector<std::string>.insert using const std::string by raic

Closed
as Fixed Help for as Fixed

0
0
Sign in
to vote
Type: Bug
ID: 596565
Opened: 9/9/2010 1:32:45 PM
Access Restriction: Public
0
Workaround(s)
0
User(s) can reproduce this bug
Each time you insert a const std::string into a std::vector<std::string> you leak 16 bytes. It's unclear as what the root problem is, so this is just one example which causes the symptoms.
Details (expand)

Visual Studio/Silverlight/Tooling version

Visual Studio 2010

What category (if any) best represents this feedback?

Reliability

Steps to reproduce

#include <crtdbg.h>
#include <vector>


int main(int argc, char * argv[])
{
int tmpDbgFlag;
tmpDbgFlag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);

tmpDbgFlag |= _CRTDBG_LEAK_CHECK_DF;
_CrtSetDbgFlag(tmpDbgFlag);

// Send all reports to STDOUT
_CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG );
_CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDOUT );
_CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG );
_CrtSetReportFile( _CRT_ERROR, _CRTDBG_FILE_STDOUT );
_CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG );
_CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDOUT );

std::vector<std::string> tempVec;

tempVec.push_back("blah1");
tempVec.push_back("blah1");
tempVec.push_back("blah1");
tempVec.push_back("blah1");
tempVec.push_back("blah1");

const std::string name = "blah1";//If this isn't const, the leak doesn't happen

tempVec.insert(tempVec.begin(),name);

return 0;
}

Product Language

English

Operating System

Windows 7

Operating System Language

English

Actual results

Detected memory leaks!
Dumping objects ->
{159} normal block at 0x00198148, 16 bytes long.
Data: <                > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD
Object dump complete.

Expected results

...No leaks.
File Attachments
File Name Submitted By Submitted On File Size  
VS2010VectorInsertMemoryLeak.zip 9/10/2010 5 KB
Sign in to post a comment.
Posted by Microsoft on 9/23/2010 at 5:46 PM
Hi,

Thanks for reporting this bug. We've already fixed it, and the fix will appear in VC11. We're also looking into releasing the fix for VC10.

If you have any further questions, feel free to E-mail me at stl@microsoft.com .

Stephan T. Lavavej
Visual C++ Libraries Developer
Posted by Microsoft on 9/12/2010 at 9:55 PM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by raic on 9/10/2010 at 5:51 AM
I've attached a demo project (hasn't shown up yet here). Simply open the project and hit ctrl+F5, the memory leaks will show up in the console window.
Posted by Microsoft on 9/9/2010 at 9:16 PM
Thanks for reporting this issue. In order to fix the issue, we must first reproduce the issue in our labs. We are unable to reproduce the issue with the steps you provided.

Please give us a demo project to demonstrate this issue so that we can conduct further research.

It would be greatly appreciated if you could provide us with that information as quickly as possible. If we do not hear back from you within 7 days, we will close this issue.

Thanks again for your efforts and we look forward to hearing from you.

Microsoft Visual Studio Connect Support Team
Posted by Microsoft on 9/9/2010 at 5:03 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.