4 ms·
It depends on how many times removed it is. Lets say it's 4 8bit ints. It can be sequentially and directly in memory like: stack: [0x01, 0x02, 0x03, 0x03]
by joe_guy 5y ago
It depends on how many times removed it is.
Lets say it's 4 8bit ints. It can be sequentially and directly in memory like:
stack: [0x01, 0x02, 0x03, 0x03]
Each int is directly next to each other in memory. But it could instead be pointers to the ints, like:
stack: [0x07002412, 0x0700241A, 0x07002424, 0x070036A0]
heap (or stack, really):
0x07002412: 0x01
0x0700241A: 0x02
0x07002424: 0x03
0x070036A0: 0x04
The CPU needs to dereference that pointer, and the cache is getting all screwed up.
That is what "void*" is doing. You're using a pointer instead of a value.
In C# this is what generics allow you to avoid.
// This is like my first memory layout above.
struct Foo<T> { public T MyField; }
vs:
// This is like the second layout above.
struct Foo { public object MyField; }
- deleted 5y ago[deleted]