s3: reduce memory consumption for s3 objects

Copying the storageClass string instead of using a pointer to the original string.
This prevents the Go garbage collector from keeping large amounts of
XMLNode structs and references in memory, created by xmlutil.XMLToStruct()
from the aws-sdk-go.
This commit is contained in:
Erik Agterdenbos 2022-12-06 00:07:08 +01:00 committed by GitHub
parent 1628ca0d46
commit a9bd0c8de6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -3052,7 +3052,8 @@ func (f *Fs) newObjectWithInfo(ctx context.Context, remote string, info *s3.Obje
}
o.setMD5FromEtag(aws.StringValue(info.ETag))
o.bytes = aws.Int64Value(info.Size)
o.storageClass = info.StorageClass
storageClass := *info.StorageClass // To prevent reference to large XML structures
o.storageClass = &storageClass
o.versionID = versionID
} else if !o.fs.opt.NoHeadObject {
err := o.readMetaData(ctx) // reads info and meta, returning an error