On 2017-06-27 11:54, John Burton wrote:
I'm coming from a C++ background so I'm not too used to garbage
collection and it's implications. I have a function that creates a
std.socket.Socket using new and connects to a tcp server, and writes
some stuff to it. I then explicitly close the socket, and the socket
object goes out of scope.

Yes. You can use "scope (exit)", unless you're already doing so.

Now the issue is that I now need to call this function more than once
every second. I worry that it will create large amounts of uncollected
"garbage" which will eventually lead to problems.

Sounds like you need a connection pool. The vibe.d [1] framework contains connection pools.

It's also possible to manually disable the GC for a while and then enable it again.

[1] http://vibed.org

--
/Jacob Carlborg

Reply via email to