http://www.codeguru.com/forum/showthread.php?t=43648
内存管理的问题
I didn't have time to get to the bottom of this --- though I suspect that it's related to COM BSTRs (or VARIANTS) and the handling/deallocation of them. There are some strict rules as to who has to free BSTR memory -- check out MSDN to get some more info on this. I've also found that heap management under Windows 2000 is quite a bit different than NT 4. There seems to be more heap optimization going on -- which causes some code (probably written incorrectly!) to blow that worked fine in NT4.
In the case of my original post, I didn't have time to go back and trace everything out, so I brought the VC++ ADO COM object into my source as a CLASS module instead of a COM object (which in this one case cleared things up). As noted above, I'm sure the issues were mine -- and related to how BSTRs or variants were being handled. Sure seems strange that ALL the addresses for all three problems were the same! Anybody have any other ideas?
下面是一个低级错误:
>>I get the above error when i return a string parameter
>>of LPCSTR type
Is it a string literal? IOW, are you doint sth. like
LPCSTR foo()
{
LPCSTR _p = "123";
return _p;
}
If so, change it to use a non-const memory area, e.g.
LPCSTR foo()
{
LPCSTR _a [] = "123";
return _a;
}
我想,道理是一样的不过,出现问题的情况会比上面复杂的多!
http://msdn2.microsoft.com/en-us/library/ms235460(d=ide).aspx
异质编译连接的问题
http://discussms.hosting.lsoft.com/SCRIPTS/WA-MSD.EXE?A2=ind0112a&L=atl&D=0&T=0&P=4234
又一个,同一内存释放了两次
而我碰到的问题不在上面的范畴之内,一个ActiveX的事件,用attachEvent多次处理后,会随机产生RtlSizeHeap错误,改用[script for="ID" event="Event" language="javascript"][/script],错误消失,在attachEvent的时候对传给事件处理程序的参数被修改了,所以产生。但为什么前者会产生这种现象呢,还不清楚!
后来在google里面找ActiveX attachEvent的相关资料,大多是关于标准HTML元素的,对ActiveX较少,不过找到一本不错的书! 构建WEB应用程序的人非常值得去读一下!http://book.itzero.com/read/others/McGraw.Hill.Osborne.JavaScript.2.0.The.Complete.Reference.Second.Edition.eBook-LiB_html/8166final/toc.html
下面的链接简单介绍了ActiveX事件处理的方法!
http://discuss.develop.com/archives/wa.exe?A2=ind0212b&L=atl&T=0&H=1&P=4599
星期二, 十月 03, 2006
订阅:
博文评论 (Atom)
没有评论:
发表评论