Home Segments Top Top Previous Next

534: Sidetrip

When you create an array of class instances, memory is set aside for addresses, but memory for the class instances is not set aside until those class instances are created. Accordingly, if you should overestimate the number of elements that you need, you waste only the memory required by the unnecessary addresses, but do not waste the memory that would be required if memory were set aside for the unnecessary class instances.

In general, setting aside memory for addresses leads to far less memory waste far less than that incurred by the alternative approach of setting aside memory for class instances.