what is fpc_initialize lazarus / 21-General ---------------------------------------------------------------------- Amir61 · 2024-02-07 07:50 Hi there,   I was doing some profiling on my program and noticed 9% of the cpu time is spent in "fpc_initialize" function. I cannot figure out how/when this function is being called? ---------------------------------------------------------------------- marcov · 2024-02-07 09:19 Afaik it is the routine that initializes structured types. ---------------------------------------------------------------------- Amir61 · 2024-02-08 06:26 Initializing their fields with their default values? What if my code is something like this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i type  TPair = record    First: WideString;     ...  end;function GetPair: TPair;begin . ..end; function Process: WideString;var  PrevPair, CurPair: TPair;  i: Integer; begin  CurPair := GetPair;  for i := 1 to 1000 do  begin    PrevPair := CurPair;    CurPair := GetPair;      end;   Result := CurPair.First + PrevPair.First;end;  In this code,  PrevPair and CurPair do not need initialization. Is there a trick to avoid this overhead? ---------------------------------------------------------------------- marcov · 2024-02-08 13:20 Without being able to investigate the compiled code (look at the assembler generated with -al) I can't really say, and only provide tips. I'm not really the big expert anyway. It might be widestring related. If you are on Windows, see if it gets better if you use unicodestring (if the code is not for COM usage, that is better anyway).  Widestring allocation and refcounting goes over the windows API. On non windows, unicode and widestring are the same. ---------------------------------------------------------------------- PascalDragon · 2024-02-08 20:08 Quote from: Amir61 on February 08, 2024, 07:26:44 amWhat if my code is something like this: Please use [code=pascal][/code], the forum software does not use markdown. ---------------------------------------------------------------------- BeniBela · 2024-02-08 23:29 Quote from: Amir61 on February 08, 2024, 07:26:44 amIn this code,  PrevPair and CurPair do not need initialization. it always initializes all managed types Arrays, strings, unicodestring, ... Quote from: Amir61 on February 08, 2024, 07:26:44 amIs there a trick to avoid this overhead? you can change the compiler i made a change for managed records https://gitlab.com/freepascal.org/fpc/source/-/merge_requests/458