Advice wanted on garbage collection of sockets for c++ programmer using D

Moritz Maxeiner via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jun 27 04:59:26 PDT 2017


On Tuesday, 27 June 2017 at 09:54:19 UTC, John Burton wrote:
> 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.

Since nobody has mentioned Allocator, yet:
As you seem to know the lifetime of the socket statically, you 
can just use std.experimental.allocator.{make,dispose} [1]. With 
regards to reusing the memory: Simply use a freelist allocator 
[2].

[1] https://dlang.org/phobos/std_experimental_allocator.html#.make
[2] 
https://dlang.org/phobos/std_experimental_allocator_building_blocks_free_list.html


More information about the Digitalmars-d-learn mailing list