随笔分类 -  Under Code

摘要:1. 对于小文件,windows提供的一般读取文件的方法完全够用了,而且performance, capacity都还可以。做法一般都是:一次把整个文件读取到内存中,再在内存中对其进行读取;主要是通过一次读取来减少I/O操作所带来的performance损耗。2. 对于大文件,尤其是动辄几G,十几G的文件(CAD文件是典型的一类),常规方法就不行了。很明显的一点就是:一次读取到内存,空间不够用了(<2G的进程空间可供使用;你也不可能全用了)windows提供了MMF(内存映射文件)机制来解决这种情况。具体API的使用这里略。只列一下读取huge file的一般思路:1)映射文件开头的映像 阅读全文
posted @ 2011-03-04 15:56 能巴 阅读(1001) 评论(0) 推荐(0)
摘要:1. both of them are used to tell how to build a project. Especially, about makefile from wiki: make is a utility that automatically builds executable programs and libraries from source code by reading files called makefiles which specify how to derive the target program.2. Makefile is used by make u 阅读全文
posted @ 2011-02-01 11:37 能巴 阅读(3690) 评论(0) 推荐(1)
摘要:元数据,metadata,最本质的解读:data about data,info about information.1.(针对dotnet)反射是一种在运行时获取和使用元数据的技术。其本质在于元数据。对应一个程序集的描述是Assembly类,对应一个Class的元数据就是Type,当然还有ConstructorInfo、 PropertyInfo、FieldInfo、EventInfo、MethodInfo、ParameterInfo、Attribute等。2.Attribute也是反射一个非常诱人的技术,它可以使用户通过声明一个Attribute而附加一些有用的功能,声明Attribute 阅读全文
posted @ 2011-01-07 17:56 能巴 阅读(348) 评论(0) 推荐(0)
摘要:1. Persistence in computer science refers to the characteristic of state that outlives the process that created it. 2. Serializatioin. In computer science, in the context of data storage and transmission, serialization is the process of converting a data structure or object into a format that can be 阅读全文
posted @ 2011-01-07 16:26 能巴 阅读(289) 评论(0) 推荐(0)
摘要:1. 理解虚函数赖以生存的底层机制:vptr + vtable。虚函数的运行时实现采用了VPTR/VTBL的形式,这项技术的基础: ①编译器在后台为每个包含虚函数的类产生一个静态函数指针数组(虚函数表),在这个类或者它的基类中定义的每一个虚函数都有一个相应的函数指针。 ②每个包含虚函数的类的每一个实例包含一个不可见的数据成员vptr(虚函数指针),这个指针被构造函数自动初始化,指向类的vtbl(虚函数表) ③当客户调用虚函数的时候,编译器产生代码反指向到vptr,索引到vtbl中,然后在指定的位置上找到函数指针,并发出调用。2. 对于一个large project,对于一个frequent u 阅读全文
posted @ 2011-01-07 15:27 能巴 阅读(244) 评论(0) 推荐(0)
摘要:在某些情况下我们需要进行远程调试(比如该程序运行需要时候全屏,或者程序在客户的机器上crash崩溃), 这时候可以使用WinDBG的远程调试功能。 WinDBG的远程调试由服务端和客户端组成,和visual studio类似。 被调试的机器是服务端(server), 我们做调试的机器是客户端(client)。 两台机器都需要安装WinDBG。 第一步, 建立WinDBG server 端。 使用 -server 参数可以使WinDBG 以服务器方式启动。 WinDBG可以用多种连接协议让客户端连接,比如命名管道(named pipe), 安全管道(secure pipe), TCP 协 阅读全文
posted @ 2011-01-04 23:37 能巴 阅读(2311) 评论(0) 推荐(0)
摘要:1. For a native C++ project in VS, once you create resource.h + res file in the project, you can manually add resources (forget about the stupid resource editor!). By default, the resources will be em... 阅读全文
posted @ 2010-08-30 15:30 能巴 阅读(281) 评论(0) 推荐(0)
摘要:Review Error Handling0. General Rules -We should pay more attention on assert usage and make it a part of the error/exception handling mechanism. -Attention: 异常是first-class的语言机制。代码分析工具可以识别出异常并进行各种监测或分... 阅读全文
posted @ 2010-08-20 12:19 能巴 阅读(194) 评论(0) 推荐(0)
摘要:When program run, each function(data, registers, program counter, etc) is mapped onto the stack as it is called. Because the function calls other functions, they too are mapped onto the stack. Thi... 阅读全文
posted @ 2010-08-20 10:49 能巴 阅读(229) 评论(0) 推荐(0)
摘要:http://msdn.microsoft.com/en-us/library/aa383751(VS.85).aspx 阅读全文
posted @ 2009-05-26 21:01 能巴
摘要:[MSDN: http://msdn.microsoft.com/en-us/library/151kt790.aspx] The Visual C++ linker now supports the delayed loading of DLLs. This relieves you of the need to use the Windows SDK functions LoadLibrary... 阅读全文
posted @ 2009-05-19 22:07 能巴 阅读(370) 评论(0) 推荐(0)
摘要:Stack unwinding (C++) When an exception is thrown and control passes from a try block to a handler, the C++ run time calls destructors for all automatic objects constructed since the beginning of the ... 阅读全文
posted @ 2009-04-16 22:23 能巴 阅读(402) 评论(0) 推荐(0)
摘要:1) 堆是由低地址向高地址扩展,栈是由高地址向低地址扩展。2) 堆是不连续的空间,栈是连续的空间。3) 在申请空间时,栈的分配要比堆的快。对于堆,先遍历存放空闲存储地址的链表、修改链表、再进行分配;对于栈,只要剩下的可用空间足够,就可分配到,如果不够,那么就会报告栈溢出。4) 栈的生命期最短,到函数调用结束时;静态存储区的生命期最长,到程序结束时;堆中的生命期是到被我们手动释放时(... 阅读全文
posted @ 2009-04-07 22:57 能巴 阅读(447) 评论(0) 推荐(0)
摘要:第一部分:基本概念 1. new和operator new 看如下代码: class MyClass {…}; MyClass * p=new MyClass; 这里的new实际上是执行如下3个过程: 1. 调用operator new分配内存 ;2. 调用构造函数生成类对象;3. 返回相应指针。 operator new就像operator+一样,是可以重载的,但是不能在全局... 阅读全文
posted @ 2009-02-23 23:31 能巴 阅读(236) 评论(0) 推荐(0)
摘要:From C++ Primer: The logical AND and OR operators always evaluate their left operand before the right. The right operand is evaluated only if the left operand does not determine the result. This evalu... 阅读全文
posted @ 2009-02-16 23:03 能巴 阅读(412) 评论(0) 推荐(0)
摘要:For the details on how to initialize a GUID, check this page http://support.microsoft.com/kb/130869. (definitely we are using a new version compiler! So get to use #include) Summary of a problem I me... 阅读全文
posted @ 2009-01-23 11:56 能巴 阅读(243) 评论(0) 推荐(0)
摘要:转载自:http://pangpengzhouwenwen.blog.163.com/blog/static/3007819220081182742178/ 1. __declspec(align(16)) struct SS{ int a,b; }; 它与#pragma pack()是一对兄弟,前者规定了对齐的最小值,后者规定了对齐的最大值。同时出现时,前者优先级高。 __declspec... 阅读全文
posted @ 2009-01-23 11:05 能巴 阅读(468) 评论(0) 推荐(0)
摘要:Essence: Wrap functions to read/write things from another module. Windows keep seperate heaps for debug and release - built DLLs and EXEs. So for example, calling a release DLL from a debug applicatio... 阅读全文
posted @ 2008-09-10 17:21 能巴 阅读(252) 评论(0) 推荐(0)
摘要:An exception is an event that occurs during the execution of a program, and requires the execution of code outside the normal flow of control. There are two kinds of exceptions: hardware excepti... 阅读全文
posted @ 2008-09-04 22:15 能巴 阅读(260) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2008-08-23 17:22 能巴 阅读(139) 评论(0) 推荐(0)