Program crash: GC destroys an object unexpectedly
eugene
dee0xeed at gmail.com
Thu Sep 23 14:55:14 UTC 2021
On Thursday, 23 September 2021 at 14:31:34 UTC, jfondren wrote:
> Nice. I thought of GC.addRoot several times but I was
> distracted by the general solution of using object lifetimes
> with it, so that a struct's destructor would call
> GC.removeRoot. For your case just pinning these and forgetting
> about them is the easiest way to do it.
Yes, these two must live until the end of main().
Moreover, in real (C) programs I (usually) do
not create state machines on the fly,
instead I keep them in pools, like RX/TX machines pools
in echo-server and in echo-client.
More information about the Digitalmars-d-learn
mailing list