and build IDE with "Optimized IDE" profile.
Ok, that I can reproduce (well I get 1GB mem usage, but that is to much too).
The issue happens when the IDE is compiled with optimization -O2 or higher.
This is 99.9% likely being caused by a bug in FPC.
https://gitlab.com/freepascal.org/fpc/source/-/commit/e9d318e7e2f772bf455a92461cd5c229e69858d8=> I have not further debugged the issue to prove that it is indeed the particular bug, but I am pretty sure.
If you must use -O2 or higher to compile the IDE, you must add -OoNOPEEPHOLE (which unfortunately takes away a good bit of the optimization)The Issue is present in FPC 3.2.0 and 3.2.2.
It should be fixed in 3.2.4
It is a bug in the optimizer part of FPC.
The bug is very hard to trigger, that is only very very specific code will be compiled incorrectly. FpDebug is know to include such code.
It is unknown, if any other part of the IDE contains code that is affected.
I am not currently sure, if the old version of FpDebug (2.0.12) already had the affected code (maybe not, since there would otherwise have been problems).
Mind that the increased mem usage is just a random outcome of the bug. The bug could cause any symptoms from incorrect data/behaviour to exceptions or hard crashes.
Yes, in theory this bug can affect any project. However as I said you need to have code with just the correct number (and types) of local vars, accessed in just the correct order, with just the correct conditional (if) statements.
So far I have only seen it happen in one function in FpDebug, and only if compiled for 64 bit Windows. (but it could happen to other 64bit targets too / afaik only 64bit, but not sure on that).