The examples seem like they would consume a lot of memory, since every update allocates a new object to the heap.  Java&#x27;s garbage collection solves this, but does anyone know of an annotation or method to use to mark the old object as unused so the runtime can deallocate the old object as soon as the new object is created, rather than waiting for a stop-the-world gc pause?  I guess a better way to handle this would be to return a new object with most of the attribute references unchanged, besides the updated fields.