delete 的时候出错

yinhui8079 2013-05-02 05:04:59
NTDLL! 7c92120e()
NTDLL! 7c97f924()
NTDLL! 7c98f247()
NTDLL! 7c98302c()
KERNEL32! 7c85f9a7()
_CrtIsValidHeapPointer(const void * 0x01b22908) line 1697
_free_dbg_lk(void * 0x01b22908, int 1) line 1044 + 9 bytes
_free_dbg(void * 0x01b22908, int 1) line 1001 + 13 bytes
operator delete(void * 0x01b22908) line 49 + 16 bytes
CMyX264Decode::`scalar deleting destructor'(unsigned int 1) + 56 bytes
VIDEO_Decode_StopDecompress(void * & 0x01b22908) line 319 + 32 bytes
HGRENDER! 00cfb64b()
HGRENDER! 00cfe6a7()
HGRENDER! 00cf60ac()
CVideoRemote::StopPreview() line 168
CMediaControl::StopRecvVideo(unsigned short 20416) line 328 + 13 byte
程序能够正常运行,但是在关闭的时候会报错 应该是是在dlete的时候出错了 有没有哪位大牛 看出为什么啊 纠结 百思不得
if( hDecoder )
{
CVideoDecoder *pDecoder = (CVideoDecoder *)hDecoder;
pDecoder->StopDecompress();
if (pDecoder)
{
delete pDecoder ;
pDecoder = NULL ;
}
/*delete pDecoder;*/
hDecoder = NULL;
}
...全文
448 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
spaceman10 2013-05-03
  • 打赏
  • 举报
回复
用内存泄露软件查查哪里泄露了吧。
yinhui8079 2013-05-03
  • 打赏
  • 举报
回复
引用 9 楼 Automation_dmu 的回复:
基类的析构函数有没有声明为虚函数呢?
声明为虚函数了的
yinhui8079 2013-05-03
  • 打赏
  • 举报
回复
引用 11 楼 buyong 的回复:
check if your CVideoDecoder or CMX264Decode have ReleaseHandle or similar function or not. if yes, use this function.
CVideoDecoder *pDecoder = NULL; switch( CodeType ) { case VIDEO_CODE_MYH264: pDecoder = new CMyX264Decode ; break ; case VIDEO_CODE_H264: pDecoder = new CVideoDecoderH264; break; case VIDEO_CODE_WMV9: pDecoder = new CVideoDecoderWMV9; break; case VIDEO_CODE_MPEG4: if (g_Codec_MPEG4.IsValid()) pDecoder=new CVideoDecoderMPEG4(&g_Codec_MPEG4); // pDecoder = new CVideoDecoderH264; // for test break; break; } if( !pDecoder ) { return NULL; } else { // pDecoder->SetCoderType(CodeType); } if( !pDecoder->StartDecompress( biOut )) { delete pDecoder; return NULL; } return (HANDLE)pDecoder; 是这样子得到的,就是在每次关闭的时候delete就直接 崩掉了
buyong 2013-05-03
  • 打赏
  • 举报
回复
how the 'hDecoder' is generate?
buyong 2013-05-03
  • 打赏
  • 举报
回复
check if your CVideoDecoder or CMX264Decode have ReleaseHandle or similar function or not. if yes, use this function.
就是那个党伟 2013-05-03
  • 打赏
  • 举报
回复
建议F5断点调试下,然后跟着每步参数的值和函数关系和堆栈试试
AndyStevens 2013-05-03
  • 打赏
  • 举报
回复
基类的析构函数有没有声明为虚函数呢?
yinhui8079 2013-05-03
  • 打赏
  • 举报
回复
引用 7 楼 Automation_dmu 的回复:
CVideoDecoder *pDecoder = (CVideoDecoder *)hDecoder; 把hDecoder是CVideoDecoder对象吗?还是子类对象?定义贴出来瞅瞅。
CVideoDecoder 是基类 ,CMX264Decode 是子类 ,hDecoder是子类new出来的对象 ,
AndyStevens 2013-05-03
  • 打赏
  • 举报
回复
CVideoDecoder *pDecoder = (CVideoDecoder *)hDecoder; 把hDecoder是CVideoDecoder对象吗?还是子类对象?定义贴出来瞅瞅。
yinhui8079 2013-05-03
  • 打赏
  • 举报
回复
引用 2 楼 yinhui8079 的回复:
那怎么来确认这个问题呢 求高手指教啊
引用 3 楼 starytx 的回复:
[quote=引用 2 楼 yinhui8079 的回复:] 那怎么来确认这个问题呢 求高手指教啊
F5调试一下看看是哪里出现的异常?确定你的StopDecompress(); 操作是阻塞方式的(没有牵扯多线程)[/quote] 我对多线程不是很熟悉 那怎么确认呢
yinhui8079 2013-05-03
  • 打赏
  • 举报
回复
引用 4 楼 max_min_ 的回复:
CVideoDecoder *pDecoder = (CVideoDecoder *)hDecoder; 你相当于delete掉 hDecoder指针, 你得确认你在delete掉这个指针后, 其他地方是不是 还有用到这个指针?
程序调试时一直征程的 就是在执行delete pDecoder ;时候程序报错上面的错误,大牛有什么建议
yinhui8079 2013-05-03
  • 打赏
  • 举报
回复
引用 15 楼 spaceman10 的回复:
用内存泄露软件查查哪里泄露了吧。
果然是内存泄露了 非常感谢
max_min_ 2013-05-02
  • 打赏
  • 举报
回复
CVideoDecoder *pDecoder = (CVideoDecoder *)hDecoder; 你相当于delete掉 hDecoder指针, 你得确认你在delete掉这个指针后, 其他地方是不是 还有用到这个指针?
starytx 2013-05-02
  • 打赏
  • 举报
回复
引用 2 楼 yinhui8079 的回复:
那怎么来确认这个问题呢 求高手指教啊
F5调试一下看看是哪里出现的异常?确定你的StopDecompress(); 操作是阻塞方式的(没有牵扯多线程)
yinhui8079 2013-05-02
  • 打赏
  • 举报
回复
那怎么来确认这个问题呢 求高手指教啊
starytx 2013-05-02
  • 打赏
  • 举报
回复
感觉应该是StopDecompress还没有执行完毕你下边就删除了?或者是删除时其他地方还有在使用这个pDecoder

64,648

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧