刚写完一个CST问题的教训,发现John Robbins大牛最近也写了一篇博客《Correctly Creating Native C++ Release Build PDBs》(正确地建立原生C++Release Build PDB文件),里面有不少说法跟我那篇文字近似。在这里再介绍一下John博客里面的大意。关于pdb文件的重要性,John也有另外一篇博客介绍PDB Files: What Every Developer Must Know,感兴趣的同学可以去看看。
分类: tech
-
一个CST问题的教训
最近在忙一个CST的问题,所谓CST就是客户那边过来的,需要快点完成。尽管很着急,这个问题还是来来回回的做了将近两个多礼拜,在我近期这么牛逼的状态下这已经是非常不成功的了。
-
Debug step by step(1) Memeory leak问题调试常用手段
1, check handle leak.
Use Lua script to search the codes.
2, check memory leak.
If you use CRT, you could use:
_CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
//_CrtSetBreakAlloc(182366);// http://msdn.microsoft.com/en-US/library/e5ewb1h3(VS.80).aspx
3, get performance data.
We could use PDH functions. CPDHData
4, 注释代码隔离问题。
5,
1. 加一个对象计数器, 哪种对象一直增加, 就是它了.
2. 申请比较多的类, 轮流内部增加一个 char buffer[65536], 看看内存增加是否加快, 很快就可以找出了.6, VLD boundchecker ADPlus WinDbg SysInternals-Tools (handle)
7, OANOCACHE=1
http://msdn.microsoft.com/en-us/library/ms221105.aspx
For example, if the application allocates a BSTR and frees it, the free block of memory is put into the BSTR cache by Automation. If the application then allocates another BSTR, it can get the free block from the cache. If the second BSTR allocation is not freed, IMallocSpy will attribute the leak to the first allocation of the BSTR. You can determine the correct source of the leak (the second allocation) by disabling the BSTR caching using the debug version of Oleaut32.dll, and by setting the environment variable OANOCACHE=1 before running the application.8, some tools Mozilla uses:
http://www.mozilla.org/performance/tools.html
9, 启用或禁用内存诊断可以调用全局函数 AfxEnableMemoryTracking()
#ifdef _DEBUG
CMemoryState oldMemState, newMemState, diffMemState;
oldMemState.Checkpoint();
#endif
…
(被测试的代码)
…
#ifdef _DEBUG
newMemState.Checkpoint();
if(diffMemState.Difference(oldMemState, newMemState)) {
TRACE(“Memory Leaked Here:\n\n” );
}
#endif抄袭了toplanguage讨论中的一些想法。
http://groups.google.com/group/pongba/browse_thread/thread/6c871ba9a79be74a#
-
Lua通过COM调用外部程序excel及调用windows api
为了方便起见,最好安装lua for windows,里面已经包含了很多有用的第三方模块。
-
Lua的Iterator以及函数心得
local tbl = {"one", "two", "three", ‘five’}
local count = #tbl
local inc = 0