Your Ad Here
首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 编程语言 > C/C++ > vc2005 stringstream 内存泄漏
【标  题】:vc2005 stringstream 内存泄漏
【关键字】:vc2005,stringstream
【来  源】:http://blog.csdn.net/antter/archive/2007/03/06/1522610.aspx

vc2005 stringstream 内存泄漏

Your Ad Here
Visual Studio and .NET Framework
反馈解决方法
98861. 2005 CRT memory leaks: std::basic_iostream ( affects std::stringstream, std::fstream, probably others )
std::iostream leaks memory in trivial code. This is compounded to any class that inherits from std::iostream (such as std::stringstream) also leaks.
已关闭 填写的反馈 2005/11/9 填写者 mike_n
填写者 mike_n 日期 2005/12/5
This workaround involves modifying constructors for basic_istream and basic_ostream in the source distribution of the MS Visual C++ libraries and rebuilding msvcp80.dll and msvcr80.dll. NOTE: Only the DLL builds of these libraries were tested and only the instructions for using these libraries is provided here. The code mentioned in the bug description and my own application were tested to verify the fix.

References:

P.J. Plauger, Dinkumware - Supplied the modified constructors.

"Building the Run-Time Libraries, MSDN2 online, http://msdn2.microsoft.com/en-us/library/k9a8ehy3.aspx - How to rebuild the MSVC runtime libraries.

1. Change the relevant constructor in

{C:\Program Files\Microsoft Visual Studio 8}\vc\include\istream and
{C:\Program Files\Microsoft Visual Studio 8}\vc\crt\src\istream
* directory between {} is the location of the MSVC 8 install directory

explicit __CLR_OR_THIS_CALL basic_iostream(basic_streambuf<_Elem,_Traits> *_Strbuf)
        : basic_istream<_Elem, _Traits>(_Strbuf, false),
            basic_ostream<_Elem, _Traits>(_Noinit, false)
        {    // construct from stream buffer pointer
        }

2. Change the relevant constructor in

{C:\Program Files\Microsoft Visual Studio 8}\vc\include\ostream and
{C:\Program Files\Microsoft Visual Studio 8}\vc\crt\src\ostream

__CLR_OR_THIS_CALL basic_ostream(_Uninitialized, bool _Addit = true)
        {    // construct uninitialized
        if (_Addit)
            ios_base::_Addstd(this);    // suppress for
iostream
        }

3. Rebuild the MSVC libraries by running:

{C:\Program Files\Microsoft Visual Studio 8}\vc\crt\src\bldnt.cmd
* See reference link from description for details on rebuilding the MSVC libraries.

4. Modify the Visual Studio project files

a. Properties->Linker->Input , "Ignore Specific Libraries" : msvcprt.lib;msvcrt.lib
b. Properties->Linker->Input, "Additional Dependencies" :
"{C:\Program Files\Microsoft Visual Studio 8}\vc\crt\src\build\intel\sample_p.lib"
"{C:\Program Files\Microsoft Visual Studio 8}\vc\crt\src\build\intel\_sample_.lib"
* Refer to reference link from description on details of the file naming.

5. Put the sample_p.dll and _sample_.dll in the same directory as your app ( or follow the rules for side-by-side deployment).


填写者 Mark Bartosik 日期 2006/10/27
Maybe I'm too tired but the work around from
mike_n on 12/5/2005
does not appear to compile

填写者 MikWells 日期 2007/1/15
This memory leak has been fixed in Service Pack 1, which was release to the public in December 2006. As well as installing the entire Service Pack (over 400MB) on your development machine, you will also have to install the updated VC8 distributable runtime libraries on any machine that your program run ons.

 

IEC104 Set point1:【上一篇】
C++中声明和定义的总结:【下一篇】
【相关文章】
  • 利用stringstream实现数据类型的转换。
  • vc2005 : declared deprecated warning
  • VC2005中使用IP地址控件
  • 把其他C/C++编译器集成到VC2005中
  • 约瑟夫环VC2005
  • ogre1.2.4 for vc2005 编译备忘
  • Install qt4.2.1 for vc2005 commerical edition备忘
  • VC2005中System::String转换为std::string
  • VC2005使用boost
  • 用 stringstream 出来字符串
  • 【随机文章】
  • 防止Access数据库被下载
  • (JS)Ch3 - Object Basics
  • 会话状态
  • PhotoImpact 10 视频教程-结合圓形-广告标题字
  • Spring在Web中是如何载入相关的上下文环境
  • Ajax/Amowa框架Buffalo 1.2发布
  • 数据结构要点复习
  • iframe自动设置高度代码
  • C++基础:如何在控制台输入整型数据不出错
  • sqlplus 使用总结
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 bbb软讯网络 All Rigths Reserved.