{"id":4969,"date":"2013-04-26T15:00:19","date_gmt":"2013-04-26T13:00:19","guid":{"rendered":"http:\/\/blogs.wittwer.fr\/whiler\/?p=4969"},"modified":"2013-05-03T10:34:26","modified_gmt":"2013-05-03T08:34:26","slug":"reduire-la-taille-application-delphi","status":"publish","type":"post","link":"https:\/\/blogs.wittwer.fr\/whiler\/2013\/04\/26\/reduire-la-taille-application-delphi\/","title":{"rendered":"R\u00e9duire la taille d&rsquo;une application Delphi"},"content":{"rendered":"<p>D\u00e8s que l&rsquo;on cr\u00e9e une application avec <a href=\"https:\/\/www.embarcadero.com\/fr\/products\/delphi\" title=\"Page web de Delphi\" target=\"_blank\">Delphi<\/a>, qui contient une fiche, m\u00eame si celle-ci ne fait rien de plus, on obtient une application d&rsquo;une certaine taille&#8230;<\/p>\n<div id=\"attachment_4929\" style=\"width: 140px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-4929\" src=\"\/whiler\/wp-content\/uploads\/2013\/02\/logo_delphi.png\" alt=\"Delphi\" title=\"Delphi\" width=\"130\" height=\"130\" class=\"size-full wp-image-4929\" \/><p id=\"caption-attachment-4929\" class=\"wp-caption-text\">Delphi<\/p><\/div>\n<p>Les diff\u00e9rentes options et\/ou directives que l&rsquo;on choisit peuvent influencer la taille&#8230; J&rsquo;ai test\u00e9 celles-ci qui ont \u00e9t\u00e9 port\u00e9es \u00e0 mon attention par <a href=\"https:\/\/blogs.embarcadero.com\/matthiaseissing\/\" title=\"Le blog de Matthias\" target=\"_blank\">Matthias<\/a>&nbsp;:<br \/>\n<!--more--><br \/>\n<center><a href=\"https:\/\/docwiki.embarcadero.com\/RADStudio\/XE3\/fr\/Directive_WEAKLINKRTTI_%28Delphi%29\" title=\"Directive WEAKLINKRTTI\" target=\"_blank\"><strong>WEAKLINKRTTI<\/strong><\/a> &#038; <a href=\"https:\/\/docwiki.embarcadero.com\/RADStudio\/XE3\/fr\/Directive_RTTI_%28Delphi%29\" title=\"Directive RTTI\" target=\"_blank\"><strong>RTTI<\/strong><\/a><\/center><\/p>\n<p>J&rsquo;ai ajout\u00e9 ces directives \u00e0 mon projet ainsi&nbsp;:<\/p>\n<div class=\"codecolorer-container delphi dawn\" style=\"overflow:auto;white-space:nowrap;width:480px;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/>4<br \/>5<br \/>6<br \/>7<br \/>8<br \/>9<br \/>10<br \/>11<br \/>12<br \/>13<br \/>14<br \/>15<br \/>16<br \/>17<br \/>18<br \/>19<br \/>20<br \/><\/div><\/td><td><div class=\"delphi codecolorer\"><span class=\"kw1\">program<\/span> Project1<span class=\"sy1\">;<\/span><br \/>\n<br \/>\n<span class=\"co2\">{$WEAKLINKRTTI ON}<\/span><br \/>\n<span class=\"co2\">{$RTTI EXPLICIT METHODS([]) PROPERTIES([]) FIELDS([])}<\/span><br \/>\n<br \/>\n<span class=\"kw1\">uses<\/span><br \/>\n&nbsp; Vcl<span class=\"sy1\">.<\/span><span class=\"me1\">Forms<\/span><span class=\"sy1\">,<\/span><br \/>\n&nbsp; Unit1 <span class=\"kw1\">in<\/span> <span class=\"st0\">'Unit1.pas'<\/span> <span class=\"coMULTI\">{Form1}<\/span><span class=\"sy1\">;<\/span><br \/>\n<br \/>\n<span class=\"co2\">{$R *.res}<\/span><br \/>\n<br \/>\n<span class=\"kw1\">begin<\/span><br \/>\n&nbsp; Application<span class=\"sy1\">.<\/span><span class=\"me1\">Initialize<\/span><span class=\"sy1\">;<\/span><br \/>\n&nbsp; Application<span class=\"sy1\">.<\/span><span class=\"me1\">MainFormOnTaskbar<\/span> <span class=\"sy1\">:<\/span><span class=\"sy3\">=<\/span> <span class=\"kw2\">True<\/span><span class=\"sy1\">;<\/span><br \/>\n&nbsp; Application<span class=\"sy1\">.<\/span><span class=\"me1\">CreateForm<\/span><span class=\"br0\">&#40;<\/span>TForm1<span class=\"sy1\">,<\/span> Form1<span class=\"br0\">&#41;<\/span><span class=\"sy1\">;<\/span><br \/>\n&nbsp; <span class=\"co2\">{$IFDEF DEBUG}<\/span><br \/>\n&nbsp; &nbsp; ReportMemoryLeaksOnShutdown <span class=\"sy1\">:<\/span><span class=\"sy3\">=<\/span> <span class=\"kw2\">True<\/span><span class=\"sy1\">;<\/span><br \/>\n&nbsp; <span class=\"co2\">{$ENDIF DEBUG}<\/span><br \/>\n&nbsp; Application<span class=\"sy1\">.<\/span><span class=\"me1\">Run<\/span><span class=\"sy1\">;<\/span><br \/>\n<span class=\"kw1\">end<\/span><span class=\"sy1\">.<\/span><\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>&nbsp;<br \/>\nVoici les diff\u00e9rentes tailles constat\u00e9es en compilant depuis <a href=\"https:\/\/www.embarcadero.com\/fr\/products\/delphi\" title=\"Page web de Delphi\" target=\"_blank\">Delphi XE4<\/a>, une application 32&nbsp;bits&nbsp;:<br \/>\n<center><\/p>\n<table cellspacing=\"1\" cellpadding=\"5\" border=\"1\">\n<tr>\n<th rowspan=\"3\">VCL<\/th>\n<td>Debug<\/td>\n<td colspan=\"2\">10698 Ko<\/td>\n<\/tr>\n<tr>\n<td>Release<\/td>\n<td colspan=\"2\">2275 Ko<\/td>\n<\/tr>\n<tr>\n<td>Release sans RTTI<\/td>\n<td colspan=\"2\">1902 Ko<\/td>\n<\/tr>\n<tr>\n<th rowspan=\"3\">FMX<\/th>\n<td>Debug<\/td>\n<td><img decoding=\"async\" style=\"vertical-align: middle;\" src=\"https:\/\/www.whiler.com\/freewares\/imgs\/windows.png\" alt=\"Windows\" title=\"Pour Windows\" \/> 18267 Ko<\/td>\n<td><img decoding=\"async\" style=\"vertical-align: middle;\" src=\"https:\/\/www.whiler.com\/freewares\/imgs\/mac.png\" alt=\"Sous OS X\" title=\"Sous OS X\" \/> 31551 Ko<\/td>\n<\/tr>\n<tr>\n<td>Release<\/td>\n<td><img decoding=\"async\" style=\"vertical-align: middle;\" src=\"https:\/\/www.whiler.com\/freewares\/imgs\/windows.png\" alt=\"Windows\" title=\"Pour Windows\" \/> 4802 Ko<\/td>\n<td><img decoding=\"async\" style=\"vertical-align: middle;\" src=\"https:\/\/www.whiler.com\/freewares\/imgs\/mac.png\" alt=\"Sous OS X\" title=\"Sous OS X\" \/> 7115 Ko<\/td>\n<\/tr>\n<tr>\n<td>Release sans RTTI<\/td>\n<td><img decoding=\"async\" style=\"vertical-align: middle;\" src=\"https:\/\/www.whiler.com\/freewares\/imgs\/windows.png\" alt=\"Windows\" title=\"Pour Windows\" \/> 4039 Ko<\/td>\n<td><img decoding=\"async\" style=\"vertical-align: middle;\" src=\"https:\/\/www.whiler.com\/freewares\/imgs\/mac.png\" alt=\"Sous OS X\" title=\"Sous OS X\" \/> <del style=\"color:red\">5426 Ko<\/del><\/td>\n<\/tr>\n<\/table>\n<p><\/center><\/p>\n<p>Comme vous pouvez le constater, si vous n&rsquo;utilisez pas l&rsquo;unit\u00e9 <code class=\"codecolorer delphi dawn\"><span class=\"delphi\">System<span class=\"sy1\">.<\/span><span class=\"me1\">Rtti<\/span><\/span><\/code>, vous pouvez facilement gagner de la place en utilisant ainsi ces deux directives  <img src=\"https:\/\/blogs.wittwer.fr\/whiler\/wp-includes\/images\/smilies\/skype\/\/yes.gif\" alt=\"(y)\" class=\"wp-smiley\" style=\"height: 1em; max-height: 1em;\" \/> . Cela fonctionne bien s\u00fbr \u00e9galement en 64 bits m\u00eame si je n&rsquo;ai pas mis les valeurs dans le tableau ci-dessus. <img src=\"https:\/\/blogs.wittwer.fr\/whiler\/wp-includes\/images\/smilies\/skype\/\/wink.gif\" alt=\";)\" class=\"wp-smiley\" style=\"height: 1em; max-height: 1em;\" \/> De plus, sur un projet <em>vide<\/em>, la seconde directive ne change rien. Je la conserve n\u00e9anmoins pour des projets plus cons\u00e9quents, avec du code, o\u00f9 celle-ci s&rsquo;av\u00e8re r\u00e9ellement utile.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/whiler\/wp-content\/uploads\/2010\/08\/stat_sys_warning_red.png\" alt=\"Attention !!!\" width=\"32\" height=\"32\" class=\"size-full wp-image-1503\" style=\"vertical-align: middle;\" \/>Vous remarquerez \u00e9galement que j&rsquo;ai barr\u00e9 une taille pour OS X&nbsp;; en effet, la premi\u00e8re directive n&rsquo;est pas compatible avec ce syst\u00e8me d&rsquo;exploitation. Par cons\u00e9quent, j&rsquo;utilise concr\u00e8tement ceci dans mes projets <a href=\"https:\/\/www.embarcadero.com\/fr\/products\/firemonkey\" title=\"Page web de FireMonkey\" target=\"_blank\">FireMonkey<\/a>&nbsp;:<\/p>\n<div class=\"codecolorer-container delphi dawn\" style=\"overflow:auto;white-space:nowrap;width:480px;\"><div class=\"delphi codecolorer\"><span class=\"co2\">{$IFDEF MSWINDOWS}<\/span><br \/>\n<span class=\"co2\">{$WEAKLINKRTTI ON}<\/span><br \/>\n<span class=\"co2\">{$ENDIF MSWINDOWS}<\/span><br \/>\n<span class=\"co2\">{$RTTI EXPLICIT METHODS([]) PROPERTIES([]) FIELDS([])}<\/span><\/div><\/div>\n<p>&nbsp;<br \/>\nVous pouvez ajouter et s\u00e9lectionner les configurations depuis le Gestionnaire de projets&nbsp;:<br \/>\n<div id=\"attachment_4990\" style=\"width: 266px\" class=\"wp-caption aligncenter\"><a href=\"\/whiler\/wp-content\/uploads\/2013\/04\/projects-manager.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-4990\" src=\"\/whiler\/wp-content\/uploads\/2013\/04\/projects-manager-256x300.png\" title=\"Gestionnaire de projets\" alt=\"Gestionnaire de projets\" width=\"256\" height=\"300\" class=\"size-medium wp-image-4990\" srcset=\"https:\/\/blogs.wittwer.fr\/whiler\/wp-content\/uploads\/2013\/04\/projects-manager-256x300.png 256w, https:\/\/blogs.wittwer.fr\/whiler\/wp-content\/uploads\/2013\/04\/projects-manager.png 286w\" sizes=\"auto, (max-width: 256px) 100vw, 256px\" \/><\/a><p id=\"caption-attachment-4990\" class=\"wp-caption-text\">Gestionnaire de projets<\/p><\/div><\/p>\n<p>Encore merci  <img src=\"https:\/\/blogs.wittwer.fr\/whiler\/wp-includes\/images\/smilies\/skype\/\/bow.gif\" alt=\"(bow)\" class=\"wp-smiley\" style=\"height: 1em; max-height: 1em;\" \/>  \u00e0 <a href=\"https:\/\/blogs.embarcadero.com\/matthiaseissing\/\" title=\"Le blog de Matthias\" target=\"_blank\">Matthias<\/a> pour cette astuce int\u00e9ressante&nbsp;!<\/p>\n<p>&nbsp;<\/p>\n<blockquote><p><strong>Article mis \u00e0 jour<\/strong>&nbsp;: en faisant quelques tests compl\u00e9mentaires avec <a href=\"https:\/\/blogs.embarcadero.com\/tlaborde\" title=\"Le blog de Thierry\" target=\"_blank\">Thierry<\/a>, nous avons remarqu\u00e9 que la directive <code class=\"codecolorer delphi dawn\"><span class=\"delphi\"><span class=\"co2\">{$WEAKLINKRTTI\u00a0ON}<\/span><\/span><\/code> fait planter l&rsquo;application sous <img decoding=\"async\" style=\"vertical-align: middle;\" src=\"https:\/\/www.whiler.com\/freewares\/imgs\/mac.png\" alt=\"Sous OS X\" title=\"Sous OS X\" \/>.<\/p><\/blockquote>\n<div class=\"thanks_button_div\" \n                  style=\"float: right; margin-right: 10px; margin-top:10px;\"><div id=\"thanksButtonDiv_4969_1\" style=\"background-image:url(https:\/\/blogs.wittwer.fr\/whiler\/wp-content\/plugins\/thanks-you-counter-button\/images\/thanks_compact_brown1.png); background-repeat:no-repeat; float: left; display: inline;\"\n                onmouseover=\"javascript:thankYouChangeButtonImage('thanksButtonDiv_4969_1', true);\" \n                onmouseout=\"javascript:thankYouChangeButtonImage('thanksButtonDiv_4969_1', false);\"\n                onclick=\"javascript:thankYouChangeButtonImage('thanksButtonDiv_4969_1', false);\" >\n                <input type=\"button\" onclick=\"thankYouButtonClick(4969, 'You left &ldquo;Thanks&rdquo; already for this post')\" value=\"Merci\u00a0 3\"\n                  class=\"thanks_button thanks_compact thanks_brown1\"\n                  style=\"  font-family: Verdana, Arial, Sans-Serif; font-size: 14px; font-weight: normal;; color:#00f;\"\n                  id=\"thanksButton_4969_1\" title=\"Click to leave &ldquo;Thanks&rdquo; for this post\"\/>\n             <\/div><div id=\"ajax_loader_4969_1\" style=\"display:inline;visibility: hidden;\"><img decoding=\"async\" alt=\"ajax loader\" src=\"https:\/\/blogs.wittwer.fr\/whiler\/wp-content\/plugins\/thanks-you-counter-button\/images\/ajax-loader.gif\" \/><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>D\u00e8s que l\u2019on cr\u00e9e une application avec Delphi, qui contient une fiche, m\u00eame si celle-ci ne fait rien de plus, on obtient une application d\u2019une certaine taille\u2026<br \/>\nLes diff\u00e9rentes options et\/ou directives que l\u2019on choisit peuvent influencer la taille\u2026 J\u2019ai test\u00e9 celles-ci qui ont \u00e9t\u00e9 port\u00e9es \u00e0 mon attention par Matthias&#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_links_to":"","_links_to_target":""},"categories":[7],"tags":[27,154,146,108],"class_list":["post-4969","post","type-post","status-publish","format-standard","hentry","category-delphi","tag-coloration-syntaxique","tag-delphi","tag-firemonkey","tag-script"],"_links":{"self":[{"href":"https:\/\/blogs.wittwer.fr\/whiler\/wp-json\/wp\/v2\/posts\/4969","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.wittwer.fr\/whiler\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.wittwer.fr\/whiler\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.wittwer.fr\/whiler\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.wittwer.fr\/whiler\/wp-json\/wp\/v2\/comments?post=4969"}],"version-history":[{"count":0,"href":"https:\/\/blogs.wittwer.fr\/whiler\/wp-json\/wp\/v2\/posts\/4969\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.wittwer.fr\/whiler\/wp-json\/wp\/v2\/media?parent=4969"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.wittwer.fr\/whiler\/wp-json\/wp\/v2\/categories?post=4969"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.wittwer.fr\/whiler\/wp-json\/wp\/v2\/tags?post=4969"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}