FRHIStructuredBuffer from FRDGPooledBuffer is null in some unidentified cases


I am facing a strange issue with my code using the RDG.

Inside a class I have a TRefCountPtr<FRDGPooledBuffer> Pooled_RdgPositions; which is used as the output of a compute shader that I use to generate a mesh.

In one of my RDG I do:

			[this](FRHICommandListImmediate& RHICmdList)
				FRDGBuilder GraphBuilder(RHICmdList);
				const auto RdgPositions = CreateTypedStructuredBuffer(
					GraphBuilder, TEXT("buf_OutPositions"),
					Positions, ERDGInitialDataFlags::NoCopy);
				ConvertToExternalBuffer(GraphBuilder, RdgPositions, Pooled_RdgPositions);

while in another I do:

		[this, &NumVertices, &YarnTubesInput, &DeformInput, &ShellMapInput,
			&Pooled_RdgB0, &Pooled_RdgXms, &Pooled_RdgTexAxes, &Pooled_RdgTexData, &Pooled_RdgIndices,
			&Pooled_RdgMeshF, &Pooled_RdgMeshDinvU, &Pooled_RdgMeshU, &NumOutVertices](FRHICommandListImmediate& RHICmdList)
			FRDGBuilder GraphBuilder(RHICmdList);
// omitted

	// we need to get the data from the shader back to OutVertices
	GraphBuilder.QueueBufferExtraction(RdgPositions, &Pooled_RdgPositions);

after that I am using a custom mesh component to render the data so, in order to copy the data from the structured buffer to the vertex buffer I need the FRHIStructuredBuffer which, in some frames is null without reason (I can run the app for some time before this is null).

TRefCountPtr<FRDGPooledBuffer> Pooled_RdgPositions;
FRHIStructuredBuffer* GetPositionSB() const { return Pooled_RdgPositions->GetStructuredBufferRHI(); }

Does anybody have any advice on how can I debug this issue? Not sure if it is releated to GC but it should not be with rendering code.

EDIT: CreateTypedStructuredBuffer is just a helper function I have done capable of creating a SB from a TArray. It just wraps the CreateStructuredBuffer calls.

Little update:

I have checked the code of FRDGPooledBuffer but I cannot find any cause for the StructuredBuffer beign null.

Seems that i found the cause. I need to move around the refcountptr so it does not get destroyed.