|
The suggested method for implementing string constants is to call String.new(length_of_string) and to call String.appendChar(c) for each character in the string. However, no mention is made of calling String.dispose() for the constant when it goes out of scope. If the string constant is not disposed, won't the VM eventually run out of heap space if the method containing the constant is called repeatedly? Any suggestions on how to track the constant until it goes out of scope? How should the scope be defined for this purpose? For example, if the constant is assigned to a String variable, the 'dispose responsibility' is transferred to that variable. One could imagine requiring an explicit call to 'variable.dispose()' in this case. On the other hand, if the string is used as a parameter, e.g., to Output.printString(), perhaps the string should automatically be disposed after the call to Output.printString() returns.
|