4
votes

I've started to work in home office and connected my Windows 10 PCs to the network drives in the company through VPN. I noticed there was a lot of traffic on the VPN and tried to find out why. I noticed that when I open a directory with the Windows Explorer on a network drive the data transfer is raised by hundreds of MB. So I started some tests. I disabled all Virus Scanners and so on, which might access the network drive and made multiple duplicates of the same file until i had 1GB in a directory. I made one directory with only PDFs, one with a executable from another company and one with executables made by me. A standard Delphi XE application. What I found out:

  1. If there is a directory including only PDFs. There is only a little traffic
  2. If there is a directory with an executable from another company for example the "Affinity" graphic editor. There is also only a little traffic
  3. If there is an executable made by me with Delphi XE. There is over 1GB traffic. The Windows Explorer shows the files, but not the icons. After all data is transferred the icons show up one by one.

I tried to find out why there is a difference between the two executables or what exactly is happening, but couldn't find out why and how to solve this.

1
I suggest you do a wireshark trace to see the difference - whosrdaddy
Also interested. I've noticed this phenomena for years. I have a network drive with dozens of different delphi .exe versions of a personal application and opening that directory is slow and obviously network bandwidth intensive. In my case it did appear to at least partially be Windows Defender as excluding that directory seemed to help a lot. - MarkF
I remember a while back it was mentioned Delphi built executable files have oddities with repeated sections in the EXE that caused problems debugging when Microsoft made some changes to the Windows loader. Microsoft made some changes to the loader (and I think Embarcadero made changes to exe generation) to fix the problem. A similar issue could effect Antivirus software causing the same dependencies to be checked multiple times. - Brian
Found it. From a response to a ticket about problems with the Windows creator's update: "Marco Cantù added a comment - 16/May/17 6:21 AM The issue is in fact that BPLs are loaded multiple times, due to a change (an optimization, in fact!) of the library loading code in Creators Update. Standalone executables are not affected. The negative effect is limited for standard local installations. It is significant if the BPLs are remote. It is critical when this happens under the debugger. This is for all versions of Delphi, as far as we know – going back many many years. Working on it." - Brian
The fact that programmers use computers doesn't turn every computer-related question into a programming problem. This question is off-topic. - IInspectable

1 Answers

3
votes

While I'm not sure about this I'm guessing that the cause for this is the size of resource section of Delphi executables.

You see most other compilers create executables with pretty small resource sections which contain only executable icons, version information and included manifest file.

Delphi on the other hand stores much more information in that resource section like:

  • several default mouse cursors
  • several bitmaps that store several standard icons that can be shown on various buttons
  • executable icons
  • several default strings that can be shown on various error messages
  • RCData which contains information about all included packages and all DFM's that are needed for creating forms with the same layout as they were designed during design time.
  • version information
  • built in manifest
  • and of course all other resources that you have added to your project

Because of all this the resource section of Delphi files can easily exceed several MB in size. You can use one of various PE resource viewers or resource editors to get better idea of what exactly is stored in resource sections of Executable files. I most commonly use PE Explorer for this.

And since Windows has to retrieve entire resource sections in order to be able to extract executable icons this causes so much network traffic when opening a network folder with lots of executables that were built with Delphi.