Inaccessible local variables should not leak memory
Final Release Note
Description
Although not a recommended programming practice, constructs such as the following which NEW variables in loops are not technically incorrect:
FOR … DO
. NEW a,b,c
. <some code>
If the loop is an indefinite loop, for example, if it reads and processes input until it is halted, eventually, it will result in use all available stack space. A better way to code the above is:
NEW a,b,c
FOR … DO
. KILL a,b,c
. <some code>
Code such as the first example may not be caught during development and testing, but is likely to be encountered in production. There are two possible solutions:
- When NEW'ing a variable, check whether it has already been NEW'd in the current stack frame, and if so KILL the variable instead.
- Make unreachable variables like these collectible.
Draft Release Note
Inaccessible local variables, such as those repeatedly NEW'd in a routine, no longer leak memory. Previously, they did.
Edited by K.S. Bhaskar