Shape memory effect in a spring