On Tuesday, 17 May 2022 at 11:59:10 UTC, bauss wrote:
The problem with GC is that the lifetime sometimes exceed
what's expected.
I am not sure if I get the sentence right,
but I've had program crash because GC
in some circumstances collects objects which
where supposed to have 'infinite' lifetime,
but were collected soon after program start.
(There was a thread in this forum started by me
where this was discussed).
And due to this I (just in case) had to write things like this:
```d
foreach (k; 0 .. nConnections) {
auto sm = new WrkMachine(md, rxPool, txPool, host,
port);
wrkMachines ~= sm; // <<<<<<<
sm.run();
}
```
wrkMachines array is not needed by the program itself,
it's purpose is just to keep pointers in heap as the warranty
that GC will not collect corresponding objects.