I have a flow setup in the following way:
_publisherQueue = CreateBuffer();
var batchingBlock = CreateBatchBlock(options.BatchSize);
var debounceBlock = CreateDebounceBlock(options.DebounceInterval, batchingBlock.TriggerBatch);
var publishBlock = CreatePublishBlock();
var groupByTopicBlock = CreateGroupByTopicBlock(publishBlock);
_publisherQueue.LinkTo(debounceBlock, new DataflowLinkOptions { PropagateCompletion = true});
debounceBlock.LinkTo(batchingBlock, new DataflowLinkOptions { PropagateCompletion = true });
batchingBlock.LinkTo(groupByTopicBlock, new DataflowLinkOptions { PropagateCompletion = true });
where:
CreateDebounceBlock
return a transform block (with a timer to trigger thebatchblock
)CreateGroupByTopicBlock
returns anActionBlock
whoseAction
triggers the Action block returned byCreatePublishBlock
I cannot dispose the links because this flow should live for the entire life time of the program (in this case it is a Windows Service).
I have noticed that every time I invoke _publisherQueue
(which is a BufferBlock
) some memory is used, which is normal, However after the process is finished the memory allocated is not being released.
This is worrisome due to the fact that this is a long running process that will accept inputs at random intervals.
It's my first attempt at using TPL so most probably I am not doing proper disposal. However I'm not sure what I need to dispose of since I need these structures to remain alive throughout the life time of the program.