4

In this question (link) it was said that the line below (in each unit) would remove as much RTTI as possible:

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

The posting didn't mention what Delphi version it works with, but I assume D2010. However, when I include the line above, I get this error:

    DCC Fatal Error: E2158 System unit out of date or corrupted: 
    missing TVisibilityClasses.

I'm using a "stock" version of D2010 and have never done anything that I'm aware of that would change the default installation or the libraries.

Any suggestions? TIA

Related question: link.

Community
  • 1
  • 1
RobertFrank
  • 7,332
  • 11
  • 53
  • 99
  • 2
    I haven't seen that error before, but you don't need to put that line in every unit. Just put it at the top of your DPR, before the `uses` clause. – Mason Wheeler Oct 26 '10 at 15:16
  • 3
    This is 2010, are we *still* worried about the size of our executables? I thought we were done with that back in, oh, 1998? – Lasse V. Karlsen Oct 26 '10 at 15:17
  • 2
    Lasse: I agree: it seems archaic to be worrying about size of executables. However, our niche product is delivered on CD. The CD doesn't have enough empty space to accommodate the growth that the considerably larger EXE's require... – RobertFrank Oct 26 '10 at 15:36
  • Perhaps you'd be better off using UPX to shrink the executable size instead? – glob Oct 26 '10 at 16:12
  • 1
    Did you try additing this line to a newly created (and empty) Delphi application? – gabr Oct 26 '10 at 16:18
  • glob: Yes, UPX helps, but the installer software I use does the same compression. gabr: Good suggestion to try an empty Delphi application. The directive works fine there. New results: positioning the directive as Mason suggested, before the uses clause results in F2084: Internal Error: AV0866E814-R00000010-0. I'm thinking I'm out of luck. Hard to know why this would fail here but not in an empty program.... – RobertFrank Oct 26 '10 at 17:11
  • Is it considered poor practice to cross post to the Embarcadero forum if it's posted to SO too? – RobertFrank Oct 26 '10 at 17:14
  • 2
    @Robert: While there are many users that read both the Embarcadero forums and StackOverflow, there are also plenty that do not frequent both. So ask there as well, there is no point in limiting your chances of an answer. Also, asking both on StackOverflow and in the Embarcadero forums, I would not consider cross posting as these two have nothing to do with eachother apart from both being communities where people help other people. – Marjan Venema Oct 26 '10 at 17:38
  • @Robert, why not switch from CD to DVD? Who makes CDs anymore? – Remy Lebeau Oct 26 '10 at 18:23
  • @Lasse: yes and in 2010 we are using virtualization a lot and what happens there? Virtual Machines on large VMWare environments are provisioned with smaller disks and less memory than you might expect! – Remko Oct 26 '10 at 18:29
  • @glob: the price of using UPX is that memory usage increases (almost doubles for the executable itsself) – Remko Oct 26 '10 at 18:29
  • 1
    @Lasse: I dunno, in short development cycles we often deliver patches to consultants through _email_. That's one transport mechanism that hasn't really caught up with the rapid growth of executable sizes over the last 5 delphi versions. :D – Paul-Jan Oct 26 '10 at 18:31
  • 1
    @Remko: That may have used to be true but I'm not sure it still is. From UPX-homepage: "no memory overhead for your compressed executables because of in-place decompression". – Ville Krumlinde Oct 26 '10 at 19:08
  • In case you want to further decrease the EXE file size: Putting {$SetPEFlags 1} // IMAGE_FILE_RELOCS_STRIPPED into the DPR file removes the unnecessary relocation block from the EXE. – Andreas Hausladen Oct 27 '10 at 10:59

2 Answers2

5

Make sure you put the "{$RTTI" line below the "unit unit1;" line.

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

David
  • 13,360
  • 7
  • 66
  • 130
Giel
  • 2,066
  • 20
  • 22
  • 3
    Working with suggestion led me to discover that the line fails only if it's in an include file. Putting the line in the .dpr (Thanks, Mason!) itself eliminated the problem. Exe size went from 35 megs to 32 megs. That's helpful as we try to shoehorn our app onto a CD. @Remy: thanks for the DVD suggestion. Our concern is that many customers are running older machines that don't have DVDs! :-( Thanks all for the help! – RobertFrank Oct 26 '10 at 19:58
  • @Robert: please file a bug at http://qc.embarcadero.com on this. Or send me a small sample project (anything starting with my first name at pluimers dot com will do). – Jeroen Wiert Pluimers Oct 26 '10 at 20:08
  • One further comment: sometimes this fails with F2084: Internal Error: AV06B5E814-R00000010-0 – RobertFrank Nov 02 '10 at 21:00
  • Wow... 35 MB executable? Have you considered using packages and/or an exe compression utility? Both could significantly reduce disk requirements. – Jerry Gagnon Nov 29 '11 at 04:48
2

The new RTTI is for Delphi 2010 and up.

It can be removed, but then lots of things will have limited functionality (like JSON conversion, part of DataSnap and many of the newer 3rd party libraries that do ORM or other mappings).

Things depending on TValue are gone anyway.

"old style" RTTI (which was introduced in Delphi 1 and is still present in Delphi 2010) cannot be removed.

So: it is recommended to remove RTTI only from your own units, and not from the RTL and VCL.

--jeroen

Jeroen Wiert Pluimers
  • 23,965
  • 9
  • 74
  • 154