Comment #0 by qigezx+dc40d6nao940k — 2022-10-07T16:07:24Z
Each thread where regular expressions are used leaks memory exactly once, I think that only the first created regex leaks.
This is true for (CTR) compile time and runtime regex. CTR leak much more memory. The leak grows or shrinks depending on the size of the regex.
Compile the following example with "ldc2 -fsan=address -g" to see for yourself. It also works with gdc and dmd, but at least for dmd you need to use valgrind instead, which is more ambigious and less informative in it's reporting for this bug.
```
import std;
void threadFun(){
auto rgx = regex(r"(?P<num>\d)");
auto res = matchFirst(words, rgx);
res["num"].writeln;
}
void main(){
foreach(i; 0..10){
task!(threadFun).executeInNewThread();
}
}
```
Comment #1 by qigezx+dc40d6nao940k — 2022-11-10T20:27:05Z
This is especially important when using unit_threaded as this is also when you want to enable fsan
Comment #2 by robert.schadek — 2024-12-01T16:40:32Z