limit memory use when upgrading attachments