Delphi Compiler Error
E2256 Dispose not supported (nor necessary) for dynamic arrays
Reason for the Error & Solution
The compiler has encountered a use of the standard procedure DISPOSE on a dynamic array. Dynamic arrays are reference counted and will automatically free themselves when there are no longer any references to them.
The use of DISPOSE on the dynamic array arr causes the error in this example:
program Produce; var arr : array of integer; begin SetLength(arr, 10); Dispose(arr); end.
The only solution here is to remove the offending use of DISPOSE:
program Produce; var arr : array of integer; begin SetLength(arr, 10); end.