Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2025-08

Delay when executing self-built programs (and fpc/lazarus)

11 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bart

Hi,

I've got a brand new laptop with Windows 11 (a Windows version which I don't particularly like).
It's quite a bit faster than my old Windows 10 and has 16 GB memory (the old one had 8).
I've manged to install fpc and build Lazarus from sources.

(The first app I built crashed. Took me a while to find out that this was due to changes in synedit....)

I noticed that when I start a self-built program, it takes several seconds for Windows to show the program.
This is also the case when I start fpc.exe for the first time (did not check what happens with that after a reboot).
On my Win10 laptop this is not the case and AFAIR has never been the case.

I have instructed Windows Defender to exclude all folders where my self-built apps and fpc / Lazarus reside.

I'm probably overseeing something here.

Does/did any other Win11 user experience(d) this and knows how to solve it?

Bart

Reply by email

Martin Frb
to Bart
Bart wrote
(The first app I built crashed. Took me a while to find out that this was due to changes in synedit....)

Any details, what in SynEdit? In case I broke something...

Show quoted text 8 lines
I noticed that when I start a self-built program, it takes several seconds for Windows to show the program. This is also the case when I start fpc.exe for the first time (did not check what happens with that after a reboot). On my Win10 laptop this is not the case and AFAIR has never been the case. I have instructed Windows Defender to exclude all folders where my self-built apps and fpc / Lazarus reside.

Still on Win10 (enjoying every last day...)

Defender would have been my first guess.

For FPC if you use 3.2.2 or 3.2.4RC you can try the one from the Lazarus installer => they have a codesigned fpc/ppc binary.? (not tested how much of a diff that makes / if any). And also then you should currently see a delay to the IDE itself too?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20250824/ab18d01c/attachment.htm>

Reply by email

Marc Weustink
to Bart: I've got a brand new laptop with Windows 11 (a Windows version which I don't particularly…

Hi
I'm using win11 for the last 2 years or so and use it for my daily development using Lazarus. I don't recognize this problem, but I've to admit we run several console apps (services in debug mode)

Marc

Bart wrote 24 lines
Hi, I've got a brand new laptop with Windows 11 (a Windows version which I don't particularly like). It's quite a bit faster than my old Windows 10 and has 16 GB memory (the old one had 8). I've manged to install fpc and build Lazarus from sources. (The first app I built crashed. Took me a while to find out that this was due to changes in synedit....) I noticed that when I start a self-built program, it takes several seconds for Windows to show the program. This is also the case when I start fpc.exe for the first time (did not check what happens with that after a reboot). On my Win10 laptop this is not the case and AFAIR has never been the case. I have instructed Windows Defender to exclude all folders where my self-built apps and fpc / Lazarus reside. I'm probably overseeing something here. Does/did any other Win11 user experience(d) this and knows how to solve it?

Reply by email

Werner Pamler
to Bart: I've got a brand new laptop with Windows 11 (a Windows version which I don't particularly…
Bart wrote
Does/did any other Win11 user experience(d) this and knows how to solve it?

Yes, I confirm this for Win 11 (don't have Win 10 any more). The first start of a Laz-built application is slow, next starts are immediate. Particularly annoying for the IDE which takes more than 10 seconds for the splash screen to appear. Next start is immediate again, except for the case when the IDE has been rebuilt. I guess it is caused by the Windows AV scanner. But I see the same behaviour even when I disable the AV in the settings. Not nice, but accepting the situation. I don't use a third-party AV any more because I had very "destructive experience" with the heuristics of BitDefender which had put the entire fpc tool chain into quarantaine...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20250825/4dc80ef5/attachment.htm>

Reply by email

Bart
to Martin Frb: Any details, what in SynEdit? In case I broke something... Still on Win10 (enjoying every…
Show quoted text 7 lines
(The first app I built crashed. Took me a while to find out that this was due to changes in synedit....) Any details, what in SynEdit? In case I broke something... From the top of my head:

I acces highlighter attributes via GetObjectProp()

For the freepascal highlighter, the "commentattri" (not sure about the name) used to inherit from TSynHighlighterAttributes, but now it doesn't anymore?
I had to check for another common ancestor.

See the diff I made for my application to fix this: https://sourceforge.net/p/flyingsheep/code/1153/

This part:

-function GetSynAttr(HL: TSynCustomHighlighter {TSynFreePascalSyn};
AName: String): TSynHighlighterAttributes;
+function GetSynAttr(HL: TSynCustomHighlighter {TSynFreePascalSyn};
AName: String): TLazEditTextAttribute; //TSynHighlighterAttributes;
 var
   Obj: TObject;
 begin
   try
     Obj := GetObjectProp(HL, AName);
-    if not (Obj is TSynHighlighterAttributes) then
+    if not (Obj is TLazEditTextAttribute{TSynHighlighterAttributes}) then
       Exit(nil);
-    Result := TSynHighlighterAttributes(Obj);
+    Result := TLazEditTextAttribute{TSynHighlighterAttributes}(Obj);

This part of the code handles the colorsettings and markup that are retrieved from an ini file.
The function returns nil if Obj is not of the proper type. Further on in procedure THLAttrRec.Assign, a nil parameter will cause a crash (which is probably a bad diseign choice from my part).

Bart

Reply by email

Bart
to Werner Pamler: Yes, I confirm this for Win 11 (don't have Win 10 any more). The first start of a…
Yes, I confirm this for Win 11 (don't have Win 10 any more). The first start of a Laz-built application is slow, next starts are immediate. Particularly annoying for the IDE which takes more than 10 seconds for the splash screen to appear. Next start is immediate again, except for the case when the IDE has been rebuilt. I guess it is caused by the Windows AV scanner. But I see the same behaviour even when I disable the AV in the settings. Not nice, but accepting the situation. I don't use a third-party AV any more because I had very "destructive experience" with the heuristics of BitDefender which had put the entire fpc tool chain into quarantaine...

This is just a PITA
I addeded exceptions for bothe the folder and the processes (using wildcards) just like MS says it should work (but they don't recommend it).
I went so far as to add an exclusion for my default test.exe application: it does not make any takes almost 20 seconds to launch a self written program the first time. And after each Windows update, this delay exists for all self-written programs, even the ones that were not altered an were launched many times before.

Reply by email

John Landmesser
to Bart

another reason to stay with Win 10 as long as possible ... i don't have to earn money with Win 11 :-)

Bart wrote 15 lines
On Mon, Aug 25, 2025 at 1:33?AM Werner Pamler via lazarus wrote: > Yes, I confirm this for Win 11 (don't have Win 10 any more). The first start of a Laz-built application is slow, next starts are immediate. Particularly annoying for the IDE which takes more than 10 seconds for the splash screen to appear. Next start is immediate again, except for the case when the IDE has been rebuilt. I guess it is caused by the Windows AV scanner. But I see the same behaviour even when I disable the AV in the settings. Not nice, but accepting the situation. I don't use a third-party AV any more because I had very "destructive experience" with the heuristics of BitDefender which had put the entire fpc tool chain into quarantaine... This is just a PITA I addeded exceptions for bothe the folder and the processes (using wildcards) just like MS says it should work (but they don't recommend it). I went so far as to add an exclusion for my default test.exe application: it does not make any difference at all. It takes almost 20 seconds to launch a self written program the first time. And after each Windows update, this delay exists for all self-written programs, even the ones that were not altered an were launched many times before.

Reply by email

John Landmesser
to Bart: On Mon, Aug 25, 2025 at 1:33?AM Werner Pamler via lazarus This is just a PITA I addeded…

I asked deepseek.com ( did not check that, because i have no win 11 )

Show quoted text 99 lines
Of course. Here is the information about the Lazarus/FreePascal application startup delay on Windows 11, translated and summarized in English. --- ### **Solving Lazarus/FreePascal Application Startup Delay on Windows 11** The significant startup delay for self-compiled Lazarus applications on Windows 11 is a well-known issue, primarily caused by overzealous security software (like Windows Defender) scanning the newly launched, unsigned executable. This happens frequently after Windows Updates as they can reset security databases and heuristics. Here are the most effective solutions to try: #### 1. **Optimize Compiler and Linker Options** This reduces the executable's size and complexity, making it look less "suspicious" to scanners. *? ?In Lazarus, go to **Project > Project Options > Compiler Options**. *? ?Navigate to the **Linking** section. *? ?**Enable** the following options: ? ? *? ?`-Xs` (Strip symbols from executable) ? ? *? ?`-Xg` (Disable the creation of debug information) ? ? *? ?`-WG` (Link with the GNU linker, can sometimes help) *? ?Also, ensure "**Pass linker options to linker**" is checked. #### 2. **Create Specific Anti-Virus Exclusions** Simply excluding folders is often not enough. You need to add very specific exclusions to Windows Defender (or your installed AV software). *? ?**For Windows Defender:** ? ? *? ?Go to **Windows Security > Virus & threat protection**. ? ? *? ?Under "Virus & threat protection settings," click **Manage settings**. ? ? *? ?Scroll down to **Exclusions** and click **Add or remove exclusions**. ? ? *? ?Add exclusions for: ? ? ? ? 1.? Your **Lazarus installation directory** (e.g., `C:\lazarus\`). ? ? ? ? 2.? Your **project source directory**. ? ? ? ? 3.? Your **output directory** (where the `.exe` files are built). ? ? ? ? 4.? The final compiled **`.exe` file itself** (most effective). #### 3. **Check Controlled Folder Access** This feature can block applications it doesn't recognize. *? ?In **Windows Security > Virus & threat protection > Manage ransomware protection**. *? ?If "Controlled Folder Access" is **On**, you must add your output folder to the "Allow an app through Controlled folder access" list. #### 4. **Use an Application Manifest** A manifest can help the OS correctly identify the application's compatibility level. Create a file like `your_app.manifest` and include it in your project resources. ```xml <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> ? <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> ? ? <security> ? ? ? <requestedPrivileges> ? ? ? ? <requestedExecutionLevel level="asInvoker" uiAccess="false"/> ? ? ? </requestedPrivileges> ? ? </security> ? </trustInfo> ? <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> ? ? <application> ? ? ? <!-- Windows 11 & Windows 10 --> ? ? ? <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/> ? ? ? <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/> ? ? </application> ? </compatibility> </assembly> ``` #### 5. **Code Signing (Most Effective Long-Term Solution)** Signing your executable cryptographically tells Windows that the publisher is known and the file hasn't been tampered with, bypassing most scans. *? ?**Cost:** You can purchase a code signing certificate from a Certificate Authority (e.g., Sectigo, DigiCert). *? ?**Free (for testing):** You can create a self-signed certificate and add it to your "Trusted Root Certification Authorities" store on your development machine. This won't help for distributing apps to other PCs but will fix the delay on your own machine. #### 6. **Try the Latest Lazarus Trunk Version** Development versions often include fixes for platform-specific issues. You can check out the latest source with SVN: ``` svn checkout https://svn.freepascal.org/svn/lazarus/trunk lazarus-trunk ``` #### 7. **Run Lazarus as Administrator Once** Sometimes, compiling your project once while Lazarus is running with administrator privileges can help. **Start with solutions 1 and 2 (Compiler options and AV exclusions),** as they are the most common and effective fixes for most users. If the problem persists, especially after updates, move to more robust solutions like code signing.

Reply by email

Bart
to John Landmesser
I asked deepseek.com ( did not check that, because i have no win 11 )

I even went so far as to specifically add the executable to the exclusions, both as file and as process.
This makes no difference.
It seems to me that Win11 home does absolutely nothing at all with these settings.

Completely disabling real-time security helps.

W.r.t. compiler settings: I develop in debug mode, all checks enabled and lineinfo (dwarf).
Not being able to do that (just to satisfy Windows Defender) is a no go for me.

IIRC then a manifest is included in the executable by default.

Bart

Reply by email

Martin Frb
to Bart
Bart wrote
I even went so far as to specifically add the executable to the exclusions, both as file and as process.

Google: windows 11 defender not honouring exclusion

brings up tons.

This may be interesting:
https://learn.microsoft.com/en-us/answers/questions/2812917/windows-defender-not-honoring-my-exclusions

follow the link then scroll down (mid page) to get to https://learn.microsoft.com/en-us/defender-endpoint/configure-extension-file-exclusions-microsoft-defender-antivirus#use-group-policy-to-configure-folder-or-file-extension-exclusions

Different approach, but maybe...

I have not tested it, and I don't know if it is all windows tiers...

Reply by email