Hi,
I have an intermittent problem with using the HeapMem_free() and have no idea how to solve it, any help will be greatly appreciated.
Here is the description of the system:
Processor: c6472
BIOS: 6.31.4.27
IPC : 1.22.3.23
XDC: 3.20.8.88
XDAIS : 6.23
CCS : 4.2.4.00033
Code
#define CFG_HEAP_SIZE 0x03FFFFFF
#pragma DATA_SECTION(gHeapMemMgr_Heap, ".ddr2")
Uint8 gHeapMemMgr_Heap[2][CFG_HEAP_SIZE];
HeapMem_Handle gHeapMemHandle;
HeapMem_Params heapMemParams;
int i = 0;
int numPackets =219136;
int packetSize = 512;
char *storagePtr = NULL;
// Initialize the heap handles
HeapMem_Params_init(&heapMemParams);
heapMemParams.buf = (void*) &gHeapMemMgr_Heap[0][0];
heapMemParams.size = CFG_HEAP_SIZE;
gHeapMemHandle = HeapMem_create(&heapMemParams, NULL);
// Assert if fail to create heapMem Obj
assertFatal( (gHeapMemHandle != NULL), 12345, (Uint32)gHeapMemHandle);
for( i = 0; i < 1000; i ++)
{
// Allocate memory
storagePtr = HeapMem_alloc(gHeapMemHandle , (numPackets * packetSize), CACHELINE_SIZE, &errorBlock);
// Assert if memory cannot be allocate
assertFatal( (storagePtr != NULL), 12346, (Uint32)storagePtr);
assertFatal( !Error_check(&errorBlock), 12347, Error_getCode(&errorBlock));
// Free memory
HeapMem_free(gHeapMemHandle, storagePtr, numPackets * packetSize );
}
PROBLEM:
Often time, the HeapMem_free() will free the memory without any problem. However, every once in a while the HeapMem_free() will not be able to free the memory and causing the HeapMem_alloc() to fail. And when that happens, the content of the variable "i" is fairly random.
Thanks much,
Dominic