1. for objects from class A, only their references are copied to the queue and for objects from structure B, their values are copied to the queue, am I right?
It is right. Except that the value types will be boxed.
2. For the queue, some elements are links that are small, and some elements are values that are much larger (about 408 bytes). Will it be wasteful of memory space if the queue is not small?
This is mostly true. Boxing will add another 8 bytes (4 for the sync block and 4 for type information), so for large structures that are insignificant, but for smaller structures that will represent a larger coefficient.
3. Do you have a better way to do the same?
The best thing to do is to convert this large structure into a class. There is no hard rule to know when to choose a structure or class based on size, but 32 bytes seems to be a common threshold. Of course, you can easily justify large structures based on whether you really need value type semantics, but 408 bytes probably go beyond that threshold. If a type really needs value semantics, you can make it an immutable class.
Another change you could make is to use the Queue generic class instead. Value types do not fit in the box, as they would with a regular Queue . However, you will still copy this large structure even with the general version.
source share