DRELEASE Examples
Example 1:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
This example shows the simple creation and destruction of a large DIM variable.
Example 2:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
In this example, the large variable created is associated with a second pointer variable. Note that when the second pointer is released, the original pointer is still valid and the referenced memory is unchanged. Only the second pointer is destroyed.
Example 3:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
|
|
| |
|
|
| |
|
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
|
|
|
|
|
|
|
|
This example show a more complicated scenario. A large variable is created and the pointer (pDimA) associated with it is passed to a subroutine. The process of passing the parameter creates a new pointer (pDimC) and associates it with the large variable. Upon returning from the routine, the program releases the first pointer (pDimA). The memory occupied by the large variable is not release since the pointer defined in the subroutine (pDimC) still references it. The second call to the subroutine passes in new value for pDimC. This implicity destroys the pointer which in turn releases the original memory before it is assigned to the new variable.
![]() |