Memory Management


In Java, the only way to obtain memory is to create an object. The "new" keyword is used, specifying the appropriate constructor for the class.
   ComplexFloat myValue = new ComplexFloat( 8, 4 );
There is no equivalent of "dispose" in Java. Once all references to an object have been lost, the object may be freed up by the automatic garbage collector.

To explicitly "throw away" an object, set the reference to "null"

   myValue = null;
The garbage collector can now free up the memory from that object next time it runs.