Skip to main content
deleted 10 characters in body
Source Link
Engineer
  • 30.4k
  • 4
  • 76
  • 124

TC#C# is a (memory) managed languagedlanguage, so it works primarily with references; this isreferences, not at all like unmanaged languages as are for example used for GPU shader languages. In your example, we have a reference to an array (which is 4-8 bytes) stored inside MyNode. In this way, the compiler can calculate the sizeof your struct accordingly, even though the array itself is of a variable size, it is stored in another piece of memory, not inside the struct -- again, only a reference to the array is stored inside the struct.

TC# is a (memory) managed languaged, so it works primarily with references; this is not at all like unmanaged languages as are for example used for GPU shader languages. In your example, we have a reference to an array (which is 4-8 bytes) stored inside MyNode. In this way, the compiler can calculate the sizeof your struct accordingly, even though the array itself is of a variable size, it is stored in another piece of memory, not inside the struct -- again, only a reference to the array is stored inside the struct.

C# is a (memory) managed language, so it works primarily with references, not at all like unmanaged languages as are for example used for GPU shader languages. In your example, we have a reference to an array (which is 4-8 bytes) stored inside MyNode. In this way, the compiler can calculate the sizeof your struct accordingly, even though the array itself is of a variable size, it is stored in another piece of memory, not inside the struct -- again, only a reference to the array is stored inside the struct.

added 116 characters in body
Source Link
Engineer
  • 30.4k
  • 4
  • 76
  • 124

This kind of struct setup is much faster, because all the memory is allocated together (locality of reference), and there are fewer cache misses as a consequence.

This kind of struct setup is much faster, because all the memory is allocated together, and there are fewer cache misses as a consequence.

This kind of struct setup is much faster, because all the memory is allocated together (locality of reference), and there are fewer cache misses as a consequence.

added 108 characters in body
Source Link
Engineer
  • 30.4k
  • 4
  • 76
  • 124

C#TC# is a (memory) managed languaged, so it works primarily with references; this is not at all like unmanaged languages as are for example used for GPU shader languages. In your example, we have a reference to an array (which is 4-8 bytes) stored inside MyNode. In this way, the compiler can calculate the sizeof your struct accordingly, even though the array itself is of a variable size, it is stored in another piece of memory, not inside the struct -- again, only a reference to the array is stored inside the struct.

It is because the array is separate, that your struct code can work at all (in spite of your guess).

C# is a (memory) managed languaged, so it works primarily with references; this is not at all like unmanaged languages as are for example used for GPU shader languages. In your example, we have a reference to an array (which is 4-8 bytes) stored inside MyNode. In this way, the compiler can calculate the sizeof your struct accordingly, even though the array itself is of a variable size, it is stored in another piece of memory, not inside the struct -- again, only a reference to the array is stored inside the struct.

TC# is a (memory) managed languaged, so it works primarily with references; this is not at all like unmanaged languages as are for example used for GPU shader languages. In your example, we have a reference to an array (which is 4-8 bytes) stored inside MyNode. In this way, the compiler can calculate the sizeof your struct accordingly, even though the array itself is of a variable size, it is stored in another piece of memory, not inside the struct -- again, only a reference to the array is stored inside the struct.

It is because the array is separate, that your struct code can work at all (in spite of your guess).

deleted 48 characters in body
Source Link
Engineer
  • 30.4k
  • 4
  • 76
  • 124
Loading
added 132 characters in body
Source Link
Engineer
  • 30.4k
  • 4
  • 76
  • 124
Loading
deleted 14 characters in body
Source Link
Engineer
  • 30.4k
  • 4
  • 76
  • 124
Loading
Source Link
Engineer
  • 30.4k
  • 4
  • 76
  • 124
Loading