Add free() method for proxyReader to aggressively de-allocate Read data, to handle certain out of memory conditions

There are still some more out there
This commit is contained in:
Harshavardhana 2015-06-27 20:42:49 -07:00
parent a4d20d1e75
commit ac4d8fe478

View File

@ -505,7 +505,12 @@ type proxyReader struct {
object string
}
func (r *proxyReader) free(p []byte) {
p = nil
go debug.FreeOSMemory()
}
func (r *proxyReader) Read(p []byte) (n int, err error) {
defer r.free(p)
n, err = r.reader.Read(p)
if err == io.EOF || err == io.ErrUnexpectedEOF {
ok := r.driver.objects.Append(r.object, p[0:n])
@ -582,9 +587,6 @@ func (d donutDriver) CreateObject(bucketName, objectName, contentType, expectedM
}
return "", iodine.New(err, errParams)
}
// free up
go debug.FreeOSMemory()
objectMetadata, err := d.donut.GetObjectMetadata(bucketName, objectName)
if err != nil {
return "", iodine.New(err, nil)