Skip to content

Commit

Permalink
remove usages of debug.FreeOSMemory() (#1301)
Browse files Browse the repository at this point in the history
This can be detrimental to an application due to:
- Forces a GC on every execution and blocks until the GC is complete.
- Returns OS memory immediately instead of allowing the runtime to
  re-use it.
  • Loading branch information
vcabbage authored Jun 9, 2020
1 parent e50c285 commit 51222d2
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 7 deletions.
2 changes: 0 additions & 2 deletions api-put-object-multipart.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"io/ioutil"
"net/http"
"net/url"
"runtime/debug"
"sort"
"strconv"
"strings"
Expand Down Expand Up @@ -98,7 +97,6 @@ func (c Client) putObjectMultipartNoStream(ctx context.Context, bucketName, obje

// Create a buffer.
buf := make([]byte, partSize)
defer debug.FreeOSMemory()

for partNumber <= totalPartsCount {
// Choose hash algorithms to be calculated by hashCopyN,
Expand Down
3 changes: 0 additions & 3 deletions api-put-object-streaming.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"fmt"
"io"
"net/http"
"runtime/debug"
"sort"
"strings"

Expand Down Expand Up @@ -262,7 +261,6 @@ func (c Client) putObjectMultipartStreamOptionalChecksum(ctx context.Context, bu

// Create a buffer.
buf := make([]byte, partSize)
defer debug.FreeOSMemory()

// Avoid declaring variables in the for loop
var md5Base64 string
Expand Down Expand Up @@ -386,7 +384,6 @@ func (c Client) putObject(ctx context.Context, bucketName, objectName string, re
if opts.SendContentMd5 {
// Create a buffer.
buf := make([]byte, size)
defer debug.FreeOSMemory()

length, rErr := io.ReadFull(reader, buf)
if rErr != nil && rErr != io.ErrUnexpectedEOF {
Expand Down
2 changes: 0 additions & 2 deletions api-put-object.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"fmt"
"io"
"net/http"
"runtime/debug"
"sort"
"time"

Expand Down Expand Up @@ -252,7 +251,6 @@ func (c Client) putObjectMultipartStreamNoLength(ctx context.Context, bucketName

// Create a buffer.
buf := make([]byte, partSize)
defer debug.FreeOSMemory()

for partNumber <= totalPartsCount {
length, rerr := io.ReadFull(reader, buf)
Expand Down

0 comments on commit 51222d2

Please sign in to comment.