I want to free up the memory of the array of pointers of type structNode.
struct structNode
{
int value;
}
typedef structNode * Node;
int main()
{
Node ListNodes[1000];
//Fill and Clear the array 100 times.
for(int j=0; j<100; j++)
{
//Add a pointers to the array
for(int i = 0; i < 1000; i++)
{
Node newNode = new structNode;
newNode->value = 3;
ListNodes[i] = newNode;
}
// Deleting each pointer
for(int i = 0; i < 1000; i++)
{
delete ListNodes[i];
}
// delete the array
delete [] ListNodes;
}
return 0;
}
Is this the correct way to clear the memory in each cicle? I am asking this question because I watch the program when it runs with a task manager, and it only increments the memory usage instead of keeping the memory usage at a constant range.