I want to use singleton_pool to manage memory. This is just an example which tests it.
My question: the first time i allocate 100 spot object, and free them. If i allocate some spot objects, and the number of them is less than 100. no more memory is needed, there is no need to allocate memory from os again. but the fact is another memory block is allocated.
The first block is 4016 bytes (sizeof(Spot) = 40), the second block is 8016 bytes. This is not as my imagine. Is there something wrong with these code?
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
std::cout << "size of Spot " << sizeof(Spot) << " bytes\n";
std::cout << "test singleton_pool firt time\n";
const size_t NumSpots = 100;
Spot* p1 = static_cast
participants (1)
-
李重斌