Backported fix of minimal (empty hashmap) leak on redeploy (#9993)

Change-Id: I9933c21ab8449378269c577c9622d75586590e45
Merge: no