Memory usage of SharedImagePool keeps growing
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 574
- Forks
- 104
- Avg merge
- 19m
- Merged PRs (30d)
- 1
Description
Hello, I am writing a composite component. The memory usage of the shared memory pool grows when a Join operator does not receive data from its primary stream.
The secondary stream of that Join operator is a video stream. I set delivery policies to LatestMessage so nothing should be queued at receivers' queues.
The growth of memory usage stops when a new data frame is available on the primary stream. That means, images on the secondary stream are queued, and the shared image pool is requesting more memory from the operating system.
I do not know why this happens, please help. Here is my code:
public sealed class ActionUnitDetector : Subpipeline, IProducer<IReadOnlyList<IReadOnlyDictionary<int, float>>> {
private readonly Connector<IReadOnlyList<NormalizedLandmarkList>> _inConnector;
private readonly Connector<Shared<Image>> _imageInConnector;
private readonly Connector<IReadOnlyList<IReadOnlyDictionary<int, float>>> _outConnector;
private readonly Connector<IReadOnlyList<Shared<Image>>> _alignedImagesOutConnector;
public Receiver<IReadOnlyList<NormalizedLandmarkList>> DataIn => _inConnector.In;
public Receiver<Shared<Image>> ImageIn => _imageInConnector.In;
public Emitter<IReadOnlyList<IReadOnlyDictionary<int, float>>> Out => _outConnector.Out;
public Emitter<IReadOnlyList<Shared<Image>>> AlignedImagesOut => _alignedImagesOutConnector.Out;
public ActionUnitDetector(Pipeline pipeline) : base(pipeline, nameof(ActionUnitDetector), DeliveryPolicy.LatestMessage) {
_inConnector = CreateInputConnectorFrom<IReadOnlyList<NormalizedLandmarkList>>(pipeline, nameof(DataIn));
_imageInConnector = CreateInputConnectorFrom<Shared<Image>>(pipeline, nameof(ImageIn));
_outConnector = CreateOutputConnectorTo<IReadOnlyList<IReadOnlyDictionary<int, float>>>(pipeline, nameof(Out));
_alignedImagesOutConnector = CreateOutputConnectorTo<IReadOnlyList<Shared<Image>>>(pipeline, nameof(AlignedImagesOut));
var convertedImage = _imageInConnector
.Convert(PixelFormat.RGB_24bpp, DeliveryPolicy.LatestMessage);
var aligner = new FaceImageAligner(this);
_inConnector.Join(
convertedImage,
Reproducible.Exact<Shared<Image>>(),
ValueTuple.Create,
DeliveryPolicy.LatestMessage,
DeliveryPolicy.LatestMessage
)//TODO: shared image pool grows too large when no face is detected! Fuse() does not help; swapping streams does not help. Why?
.PipeTo(aligner, DeliveryPolicy.LatestMessage);
aligner.PipeTo(_alignedImagesOutConnector, DeliveryPolicy.LatestMessage);
var inferenceRunner = new InferenceRunner(this);
aligner.PipeTo(inferenceRunner, DeliveryPolicy.LatestMessage);
inferenceRunner.PipeTo(_outConnector, DeliveryPolicy.LatestMessage);
}
}
Thank you
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the composite component shown in the issue, especially the Join call, DeliveryPolicy.LatestMessage settings, and SharedImagePool behavior. Reproduce the case where the primary stream has no data and inspect whether secondary Shared frames remain retained. Done means explaining the retention and identifying a concrete correction or confirming the behavior is expected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- stream-processing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100