After a good days work, everything seems to be working correctly. Lists are linked properly and allocate well. EXCEPT the below...and I have no idea why!!!
My 2 largest sizes are giving me trouble when building the linked list.
They are going to be 4000 x 4 and 16000 x 2.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
pListStart = &MM_pool[(sizeof(CMemoryPoolManager)+1) + 17408]; //start the new list at the end of the last one
MemoryBlock *pCurrent = (MemoryBlock *)pListStart; //pCurrent is the current "chunk" being assigned
pCurrent = (MemoryBlock *)pListStart;
for (int i=0; i < 4; i++) //there will be 4 chunks of this size
{
pCurrent = (MemoryBlock *)pListStart + i * 4000;
pCurrent->pPrevious = NULL; // at the 4th iteration it causes an
//"Unhandled exception at 0x01391275 in MemoryManager.exe: 0xC0000005: Access violation writing location 0x013c6c8d."
pCurrent->pNext = pFree4000; //assign next to head of list
if (pFree4000 != NULL) //check if its the first chunk
{
pFree4000->pPrevious = pCurrent; //linked list stuff.
}
pFree4000 = pCurrent;
}
|
it cant be because I am running out of space in the memory pool because I even changed the "start list" to start at the beginning of the memory pool to test it(it has a size of 65536)
4000x4 (or 16000) should fit in the pool.
Im having trouble understanding why it would throw an error at pCurrent->pPrevious = NULL on the 4th iteration.
I havent had this problem on any other smaller sizes.
Anyone have any ideas on what could be the cause of the problem?
If you need any other information, i'd be glad to supply it.
Hopefully someone can shed some light as I have been battleling with this problem for a few hours now.
Thanks!