今日见到的,虽然未用上D2010不过先记录下来。
扩充的RTTI信息将使编译生成的文件大小巨幅增大,而如下是关闭RTTI的方法:
有一些方案大大减少最终的可执行文件的大小有所:
{$WEAKLINKRTTI ON}或dcc32 - weaklinkrtti命令行选项
但是,重新编译选择的RTL和VCL单位,必须消除许多实际运行时类型的数据,使用此指令:
{$RTTI EXPLICIT METHODS() PROPERTIES() FIELDS()}
在显性的原因后,这个问题在文件中定义的任何类不继承父类RTTI的设置,而方法,属性和外地条款表明,无超期RTTI的应在任何级别的能见度任何生产这些元素。
拥有一个体面的RTTI的水平,在默认情况下可以利用的手段,第三方库可以假设它的存在。默认级别包括所有领域,这意味着对象图(模外部资源的链接)的,例如运行时类型信息序列化的默认二进制级别,公共方法和属性,具有RTTI的意味,例如容器使用控制反转可以适用于默认对象。
英文原文:
There are some options which reduce the final executable size somewhat:
{$WEAKLINKRTTI ON} or dcc32 –weaklinkrtti command-line option
But a recompile of choice RTL and VCL units is required to eliminate much actual RTTI data, using this directive:
{$RTTI EXPLICIT METHODS() PROPERTIES() FIELDS()}
The ‘EXPLICIT’ causes any classes defined after this point in the file to not inherit RTTI settings from the ancestor class, while the method, property and field clauses indicate that no extended RTTI should be produced for any of these elements at any level of visibility.
Having a decent level of RTTI available by default means that third-party libraries can assume its existence. The default level includes RTTI for all fields, which means that object graphs (modulo external resource links) are e.g. serializable at the binary level by default; public methods and properties having RTTI means that e.g. containers using Inversion of Control can apply to objects by default.