首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

AllocSysString() 内存储器泄露,很奇怪

2013-03-01 
AllocSysString() 内存泄露,很奇怪!m_pFailRecordset-Open(_bstr_t(cs_sql.AllocSysString()),_variant_t

AllocSysString() 内存泄露,很奇怪!
m_pFailRecordset->Open(_bstr_t(cs_sql.AllocSysString()),_variant_t((IDispatch*)(pApp->m_pConnection),true),adOpenDynamic,adLockOptimistic,adCmdText);

这段代码我用在timer中,每timer一次程序内存增加4k,但去掉AllocSysString() 内存泄露解决,如果不用在timer中又不会有泄露,有谁知道为什么?

[解决办法]
SysFreeString
[解决办法]
MSDN原文:仅供参考

Commonly, if this string is passed to a COM function as an [in] parameter, then this requires the caller to free the string. This can be done by using SysFreeString, as described in the Windows SDK. For more information, see Allocating and Releasing Memory for a BSTR. 


[解决办法]
没调用SysFreeString 来释放

热点排行