我有一些奇怪的堆损坏,并尝试使用_CrtCheckMemory发现它.
如果_CrtCheckMemory函数返回true,它是否意味着100%内存*没问题?
我认为当它返回false时很明显,那么内存中出现了问题.
相关代码是:
assert( _CrtCheckMemory() ); renderText( x + (max_height/4.0) * w,y + (fm.descent() + (label.shadedText ? 1.0 : 0.0)) * h,0.0,label.text,label.font ); assert( _CrtCheckMemory() );
第一个调用返回true,但第二个调用返回false.
renderText是一个QGLWidget :: renderText调用,label是调用renderText之前和之后的有效对象.
*:我的意思是堆
解决方法
根据我的经验,_Crt …调试功能很好,但是很轻,因此不是万无一失的.你应该把测试推到fm.descent()里面