Without code we can't do much, but it is likely that you forgot a lot a lot of string parameters (or other refcounted types) to be declared as const parameters, which will lead to an infinite amount of copying, especially when nested. But that's still just a guess. We really need a code example for sound advice. The guessed scenario about const passing will not lead to memory leaks shown by heaptrc, but will lead to resource exhaustion and so to the use of OS swap use. In that case it is the swapping in and out of physical memory that would cause a significant slow-down of your application and while there are still no real memory leaks.
E.g.:
{$mode objfpc}{$H+}
// not this
function SomeFunction(s:string):string;
//but like this
function SomeFuntion(const s:string):string;
The first will easily lead to resource exhaustion when nested, the second won't...Both will not cause real memory leaks, but the second example is
much more resource efficient.
A
single function that gets called very often will show a significant slow down because what I described above. So examine your code and correct where appropriate.
But it remains just a guess by an old hand...Old hands are often right, but not always. Without seeing actual code, that is.
Note it does not matter what kind of function or procedure: they may be class members too. If possible adjust your code to use the second pattern.