O
O.B.
I'm a little unfamiliar with how the garbage collector works in C#.
First my example:
[StructLayout(LayoutKind.Explicit)]
public unsafe struct TestClass {
[FieldOffset(0)]
fixed byte buffer[1400];
[FieldOffset(0)]
TestA testA;
[FieldOffset(0)]
TestB testB;
}
public class MyTest {
static public TestClass convert(byte[] data) {
TestClass temp;
Marshal.Copy(data, 0, (IntPtr)(&test), sizeof(TestClass));
return temp;
}
}
It is my understanding that "temp" was created on the stack within
"convert" and may be susceptible to getting snatched by the garbage
collector, correct? Or am I just being paranoid?
First my example:
[StructLayout(LayoutKind.Explicit)]
public unsafe struct TestClass {
[FieldOffset(0)]
fixed byte buffer[1400];
[FieldOffset(0)]
TestA testA;
[FieldOffset(0)]
TestB testB;
}
public class MyTest {
static public TestClass convert(byte[] data) {
TestClass temp;
Marshal.Copy(data, 0, (IntPtr)(&test), sizeof(TestClass));
return temp;
}
}
It is my understanding that "temp" was created on the stack within
"convert" and may be susceptible to getting snatched by the garbage
collector, correct? Or am I just being paranoid?