Garmaine Staff asked 1 year ago

My understanding is that a WeakHashMap keeps a soft reference to keys that will be removed if a GC happens and those objects are not referenced anymore by anybody else.

However I was wondering if we are talking about removing the elements at a:

  • full GC of the old gen (and data in the WeakHashMap can actually be promoted from young gen to old), or
  • at young gen (data is not promoted to old gen if not referenced by anybody else)

Are there different implementations to achieve the two behaviors?

In my specific case, promoting things to old gen, is particularly dangerous due to the large stall time this could cause at full GC