In this section:
This error is generated whenever a pointer assignment occurs which will prevent a block of dynamically allocated memory from ever being freed. Normally this happens because the pointer being changed is the only one that still points to the dynamically allocated block.
Memory leaked as a result of pointer reassignment
The following code allocates a block of memory then reassigns the pointer to the block to a static memory block. As a result, the dynamically allocated block can no longer be freed.
Diagnosis at Runtime
- Line 2: Source file and line at which the problem was detected.
- Line 3: Description of the problem and the expression that is in error.
- Line 4: Description of the block of memory that is about to be lost, including its size and the line number at which it was allocated.
- Line 8: Stack trace showing the function call sequence leading to the error.
In many cases, this problem is caused by simply forgetting to free a previously allocated block of memory when a pointer is reassigned. For example, the leak in the example code can be corrected as follows:
Some applications may be unable to free memory blocks and may not need to worry about their permanent loss. To suppress these error messages, suppress
LEAK_ASSIGN in the Suppressions Control Panel.