[fpc-devel] Memory leak on BeginThread() when RTL compiled with -O2
Yuriy Sydorov
jura at cp-lab.com
Thu May 20 16:30:49 CEST 2021
Hello,
I've take a look at you RTL compile script and found the mess with the compiler options.
When compiling RTL you should disable reading of options from fpc.cfg using the -n switch.
When compiling the system unit use the -Us switch.
Additionally specify only CPU/Target and optimization options -O<x>.
No other options are required for Windows RTL.
When RTL is properly compiled, even with -O2, your test program works without memory leaks.
Yuriy Sydorov,
jura at cp-lab.com
On 20.05.2021 15:43, NetSpirit via fpc-devel wrote:
> RTL not modified. Just recompilation of 'sysinitpas.pp' unit with some
> options causes problem.
>
> Here is another test project that uses your current official FPC
> installation with unmodified RTL:
> http://dl.free.fr/ePtkQwgJJ
>
> Test project contains source of 'sysinitpas.pp' (and required
> 'sysinit.inc', 'systlsdir.inc').
> Used version 3.2.2 RC1. If you have another - get sources for your version.
>
> Script 'compile.bat' compiles 'sysinitpas.pp' and then - test project
> 'test.pp'.
> See comments inside.
>
> 'test_bad.exe' shows growing memory consumption.
>
>
>> Hello,
>>
>> Your test program runs fine when compiled with FPC 3.2.0 using the
> official RTL compiled with -O2. No memory leak.
>> I suppose the issue is caused by your modifications to RTL. -O2
> (regvars) just triggers the problem in the modified RTL code which is
> hidden when regvars are disabled.
>
> _______________________________________________
> fpc-devel maillist - fpc-devel at lists.freepascal.org
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
>
More information about the fpc-devel
mailing list