
No, that need not be. If the compiler sees that it's never referenced again, it can be garbage collected (assuming the consumption pattern of msg allows that to be garbage collected incrementally).
Try out whether your programme has a space leak by giving it a long input. If it has, ask again.
Ok, I'll see if I have any problems. What I'm doing seemed like it might be the wrong way to go, so I figured I'd ask about it to see if I got any "don't do that" type responses. Sounds like what I'm doing is pretty much sane, so I'll see if I run into any trouble.
Normally, that shouldn't be necessary. If you're done with some data, it should be garbage collected pretty soon. There are some situations where an unintended and unneeded reference to some data is kept around and prevents it from being collected, but in general, the compilers are rather good at managing memory.
Thanks for the info. I'll be back if I have any trouble :)