delphi xe disable RTTI

故事扮演 提交于 2019-12-17 12:34:12

问题


i have use delphi xe recently but exe size is very big because of rtti(i think)

howto remove rtti , and can i make my application size as small as delphi 2009 application(490 kb) without comprssion; and what is the use of rtti


回答1:


In short (full story provided by links in the splash's answer):

{$RTTI EXPLICIT METHODS([]) PROPERTIES([]) FIELDS([])}

Note that as of XE6 and newer, this needs to be in each individual unit for which you want to disable RTTI. Before that (XE5 and below) it could be in the DPR file and would apply to all units in the project.




回答2:


Read the Online Help for Delphi ...

  • Working with RTTI
  • RTTI directive

... and search Stack Overflow:

  • Why should I care about RTTI in Delphi?
  • Practical usage for Delphi's new RTTI

Keep in mind that the $RTTI directive has to be included in every unit where it should take effect. See How can I set the $RTTI directive for the entire project?




回答3:


Your problem is not related to RTTI. If you are talking about relatively small increase (100-200K), this is due to extra functions in RTL (added for Unicode support etc). If you get 500-700K increase or so, then check whether you link VCL UI units (Forms, Controls etc). If you get 3Mb increase, then you've turned on extra debug symbols.




回答4:


It's because some generics functionality has been added to sys units. Generics were added in 2009 but in systems units some classes were rewritten with generics in xe and xe2. imho

Add this flags to reduce the size in dpr file (Project > view source) to each individual unit (as of XE5)*.

{$SETPEFlAGS IMAGE_FILE_DEBUG_STRIPPED or IMAGE_FILE_LINE_NUMS_STRIPPED or
 IMAGE_FILE_LOCAL_SYMS_STRIPPED OR IMAGE_FILE_RELOCS_STRIPPED}

{$WEAKLINKRTTI ON}
{$RTTI EXPLICIT METHODS([]) PROPERTIES([]) FIELDS([])}

(*) Note that as of XE5 and newer, this needs to be in each individual unit for which you want to disable RTTI. Before that (XE4 and below) it could be in the DPR file and would apply to all units in the project.




回答5:


I do not think it is RTTI what adds so much size overhead to your application. How do you know it is?



来源:https://stackoverflow.com/questions/3975292/delphi-xe-disable-rtti

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!