From a9bd0c8de6e74460ab990269e1f96834889304d2 Mon Sep 17 00:00:00 2001 From: Erik Agterdenbos Date: Tue, 6 Dec 2022 00:07:08 +0100 Subject: [PATCH] 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. --- backend/s3/s3.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/s3/s3.go b/backend/s3/s3.go index 9de4a7e6a..5fad59ae5 100644 --- a/backend/s3/s3.go +++ b/backend/s3/s3.go @@ -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