I tried to look at the behavior of the new allocator and why it does not put the data in contact.
My code is:
struct ci {
char c;
int i;
}
template <typename T>
void memTest()
{
T * pLast = new T();
for(int i = 0; i < 20; ++i) {
T * pNew = new T();
cout << (pNew - pLast) << " ";
pLast = pNew;
}
}
So, I ran this with char, int, ci. Most distributions were fixed in length from the latter, sometimes there were odd transitions from one available block to another.
sizeof (char): 1
Average jump: 64 bytes
sizeof (int): 4
Average jump: 16
sizeof (ci): 8 (int should be placed in 4-byte align)
Average jump: 9
Can someone explain why the allocator is so fragmenting the memory? Also why the leap for char is much bigger than ints and the structure that contains both int and char.