delphi xe disable RTTI
Asked Answered
B

5

10

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

Boche answered 20/10, 2010 at 6:35 Comment(1)
How big is your exe? What do you expect?Watercool
W
17

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.

Willumsen answered 20/10, 2010 at 6:48 Comment(5)
+1 for the exact statement, which you would otherwise need to find by digging through the docs as they are mostly geared towards how to use it instead of how to turn it off.Yasmineyasu
Your RTTI statement, when used on my D2010 results in the compiler error: DCC Fatal Error: E2158 System unit out of date or corrupted: missing TVisibilityClasses. Any suggestions?Dealt
Only this: docwiki.embarcadero.com/RADStudio/en/…missing'%25s'_%28Delphi%29 Are you trying to recompile system unit? Maybe you should ask a new question here - more people will see it that way.Willumsen
why this isnt by default off in DLL projects? If there is no performance diffrenceBibliofilm
Link: docwiki.embarcadero.com/RADStudio/Alexandria/en/… says: scope: local (the link in the answer is not available anymore)Ostensorium
N
8

Read the Online Help for Delphi ...

... and search Stack Overflow:

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?

Nickelsen answered 20/10, 2010 at 6:40 Comment(1)
+1 for the links to background info, though it would have been nice had you provided the statement gabr now did directly in your answer.Yasmineyasu
B
7

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.

Byrd answered 20/10, 2010 at 8:12 Comment(5)
but i think Unicode is already in Delphi 2009 (basic app only 499 kb ) but theres is no large improvement in Delphi xe vcl (delphi xe app size 800 kb)so ithink the extra 300 kb is mosty form RTTI. and d2007 apps (without unicode is ~350 kb)Boche
And why do you think RTTI was not present in Delphi 2009?Perennial
@Eugene: why do you think it's Unicode functions if the Unicode functions replaced the ANSI ones, rather than being added? And where is the "smart linker" everyone is talking about w.r.t. Delphi? ... if it can't figure out that large parts of the code are not necessary, it's perhaps not so smart after all.Beatify
@STATUS_ACCESS_DENIED Unicode functions didn't replace ANSI functions, but extended them. I.e. for some functions there exist both ANSI and Unicode variants now.Perennial
@Eugene: and aren't those we're talking about still runtime functions only? And if the strings that end up as constants or static data in my binary anyway are Unicode, why doesn't the so-called "smart linker" throw out the functions that uselessly take up space in my binary? I get your point, though. I suppose the way Unicode was implemented (and carried over as a legacy) doesn't make things better.Beatify
S
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.

Semite answered 19/7, 2012 at 18:6 Comment(0)
R
3

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

Retinoscope answered 20/10, 2010 at 7:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.