Clear out ClientCache when UI is detached to prevent a minor memory leak (#12220)
* Clear out ClientCache when UI is detached to prevent a minor memory leak (#12199)
* Clear out ClientCache when UI is detached to prevent a minor memory leak
Implemented with a listener rather than direct call from UI.detach() in
order to avoid new public API, since the whole feature has been marked
for removal. This doesn't yet prevent the cache or the type map from
getting slightly bloated during the UI's lifetime.