Limit the size of generics._generic_types_cache and generics._assigned_parameters to avoid unlimited increase in memory usage.