Question: I'm writing a JRPG style game at the moment, and am defining my items/enemies etc. in YAML files. Rather than load them at runtime (which is proving to be a pain in Scala, especially on Android) I decided to pre-compile them into a Scala object as lazy values.

My only worry is that eventually, as these values are accessed, the object will begin taking up more memory than is really needed.

Is there anyway to reinitialize a Scala object or to clear the lazy values back to their default state? Alternatively, is there a better way to accomplish what I'm trying to do here?

Answer: 
There is no such mechanism. Once a `lazy val` is accessed and its initializer is evaluated, the resulting value is held in a field of the instance of which it is a part like any other and only that instance becoming garbage itself will relinquish the reference to that "lazy" value and (possibly) allow it to be reclaimed as well. Naturally, if there are other references to it, they will preclude its being reclaimed.
I think that there's no built-in mechanism for it, so you'll need to implement it yourself. The simplest solution would be to have some form of a cache with expiry after certain time passes - for example, as described in [Java time-based map/cache with expiring keys](https://stackoverflow.com/questions/3802370/java-time-based-map-cache-with-expiring-keys).