Consider a worker loop that has something like:
...
auto msg = new immutable(DataWrittenMsg)(bytesWritten);
masterTid.send(msg);
...
Will this slowly but surely eat up all RAM, as time reaches Inf? Or can unused immutable data get collected by the GC?
(I'm reading TDPL Ch. 13 and I get the impression once immutable data is set it can never get unset?)
No, the GC will still pick up unreferenced objects, regardless of their constness.
Regarding "once immutable data is set it can never get unset" - this is only so in the logical sense. Assuming your program's memory safety isn't compromised, all immutable heap-allocated objects your program has access to will not change for as long as they're reachable, even though the actual memory at that address can be reused once those objects become unreachable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With