• Bugslayer's Tips(持续更新中...)


    http://www.wintellect.com/resources/bugslayer/Default.aspx

    Tip #1
    Get rid of the MSDEV splash screen when using Just In Time debugging. First, run REGEDIT and open the key HKEY_LOCAL_MACHINE\Software\Microsoft\ Windows NT\CurrentVersion\AeDebug. Then, change the Debugger key from "\msdev.exe -p %ld -e %ld" to "\msdev.exe -nologo -p %ld -e %ld."

    Source: http://www.microsoft.com/msj/1097/bugslayer.aspx

    如何在JIT调试的时候去掉MSDEV的启动画面。打开注册表键值:HKEY_LOCAL_MACHINE\Software\Microsoft\ Windows NT\CurrentVersion\AeDebug,修改“Debugger”键值为“\msdev.exe -nologo -p %ld -e %ld”。

    Tip #2 Always check CloseHandle's return value. Even though there is not much you can do when CloseHandle returns FALSE, it is generally indicative of a serious problem. Since Win32 will reuse handle values, it is quite easy to accidentally close an open handle being used elsewhere in your code, causing weird random bugs. When you call CloseHandle on a handle that has already been closed, it can sometimes cause random crashes that are impossible to track down. Place all your calls to CloseHandle in VERIFY macros so that you stand a fighting chance of finding those bugs in _DEBUG builds. (Thanks to Jim Austin.)

    Source: http://www.microsoft.com/msj/1097/bugslayer.aspx

    记得检查CloseHandle函数的返回值。即使CloseHandle函数返回FALSE的时候你做不了什么也要检查,FALSE往往意味着出现了一个重大的问题。当你为一个已经关闭的句柄调用CloseHandle函数,可能会出现偶然而且是难以跟踪的崩溃。

    Tip #11 One simple thing I've learned to do is to invalidate that which has been deallocated. For example, if you delete a pointer, set that pointer to NULL immediately afterward. If you close a handle, set that handle to NULL (or INVALID_HANDLE_VALUE) immediately afterward. This is especially true when these are members of a class. By setting a pointer to NULL, you prevent double delete calls. delete NULL is valid. (Thanks to Sam Blackburn, sblackbu@erols.com.)

    Source: http://www.microsoft.com/msj/0898/bugslayer0898.aspx

    在取消内存分配之后马上使它失效,删除一个指针或者关闭一个句柄之后,马上设置为NULL,这样可以避免再次删除所产生的错误,因为删除NULL值是允许的。
  • 相关阅读:
    解析XML文件时做得修改
    NSOprationQueue 与 GCD 的区别与选用
    UIPickerView(选择器)
    iOS NSDatePicker
    Http协议三次握手过程
    iOS之KVO和KVC
    iOS中使用RSA对数据进行加密解密
    Demo1_iOS9网络适配_改用更安全的HTTPS
    layer 的常用属性
    IOS OC声明变量在@interface括号中与使用@property的区别
  • 原文地址:https://www.cnblogs.com/s5689412/p/132168.html
Copyright © 2020-2023  润新知