How to find out binary size of a UStruct?

For a given dynamically-sized serializable USTRUCT, i.e.

USTRUCT()
FSomeStruct
{
   GENERATED_BODY()

   UPROPRETY()
   TArray<float> SomeData;

   UPROPRETY()
   FString SomeString;

   friend FArchive& operator<< (FArchive& Ar, FSomeStruct& Struct) {
        Ar << Struct.SomeData;
        Ar << Struct.SomeString;
        return Ar;
   }
};

What is the correct way to get the binary size (in bytes) of an instance of this USTRUCT? For example, the instance has 15 floats in the SomeData array, and a string with 20 characters.

I mean the size it would occupy in an FArchive when serialized with the << operator, like an FBufferArchive.

I understand that a reliable way would be to actually serialize it into a FBufferArchive, and then see the difference in the container’s size before/after, but I don’t want/need to actually serialize it and waste memory and instructions. I just need to know the size.

I assume there is some easy way of knowing this?

I have found the UStruct::GetStructureSize() function, but I don’t know if it’s what I need, and apart from that I can’t seem to get the FSomeStruct as a UStruct, to actually be able to call it.

I hope someone here can help out with this, it would be much appreciated!

Probably it is no longer relevant but may be useful for future seekers as myself… In relation to the example, the next code can be used to get the size of USTRUCT in bytes:

const UStruct* SomeStruct = FSomeStruct::StaticStruct();
SomeStruct->GetStructureSize();