﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-CocoWang</title><link>http://www.cppblog.com/CocoWang/</link><description /><language>zh-cn</language><lastBuildDate>Fri, 01 May 2026 08:51:51 GMT</lastBuildDate><pubDate>Fri, 01 May 2026 08:51:51 GMT</pubDate><ttl>60</ttl><item><title>_ASSERTE(_CrtIsValidHeapPointer(pUserData))错误详解</title><link>http://www.cppblog.com/CocoWang/archive/2014/01/15/205386.html</link><dc:creator>CocoWang</dc:creator><author>CocoWang</author><pubDate>Wed, 15 Jan 2014 06:11:00 GMT</pubDate><guid>http://www.cppblog.com/CocoWang/archive/2014/01/15/205386.html</guid><wfw:comment>http://www.cppblog.com/CocoWang/comments/205386.html</wfw:comment><comments>http://www.cppblog.com/CocoWang/archive/2014/01/15/205386.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/CocoWang/comments/commentRss/205386.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/CocoWang/services/trackbacks/205386.html</trackback:ping><description><![CDATA[ 可能原因：DLL和EXE主程序使用的不是同一个堆造成。

解决办法：
1. 采用谁分配谁释放的原则；
2. 绕过 new 和 delete，使用 GlovalAlloc 和 GlobalFree；
3. 更改工程选项， release 版本肯定不会出现这个失败，这个只会存在 debug 状态下，但是 release 会出现内存泄漏.

更改 debug 下 dll 和 exe 运行库为动态编译即： multi-threaded debug dll.

因为 multi-thread debug dll 运行库编译使编译器为所有dll共享分配的堆。这样就不会存在多个释放过程，也就不会出现问题了.<img src ="http://www.cppblog.com/CocoWang/aggbug/205386.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/CocoWang/" target="_blank">CocoWang</a> 2014-01-15 14:11 <a href="http://www.cppblog.com/CocoWang/archive/2014/01/15/205386.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>