You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by lc...@apache.org on 2017/12/22 17:27:16 UTC

[beam] branch go-sdk updated: Store objects in pool so they can be reused.

This is an automated email from the ASF dual-hosted git repository.

lcwik pushed a commit to branch go-sdk
in repository https://gitbox.apache.org/repos/asf/beam.git


The following commit(s) were added to refs/heads/go-sdk by this push:
     new 412de6f  Store objects in pool so they can be reused.
412de6f is described below

commit 412de6f1071d84c72d731741cb44ff0b818e3553
Author: Bill Neubauer <wc...@google.com>
AuthorDate: Wed Dec 20 11:37:07 2017 -0800

    Store objects in pool so they can be reused.
---
 sdks/go/pkg/beam/core/runtime/harness/session.go | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/sdks/go/pkg/beam/core/runtime/harness/session.go b/sdks/go/pkg/beam/core/runtime/harness/session.go
index 135f589..67f577f 100644
--- a/sdks/go/pkg/beam/core/runtime/harness/session.go
+++ b/sdks/go/pkg/beam/core/runtime/harness/session.go
@@ -101,6 +101,7 @@ func recordMessage(opcode session.Kind, pb *session.Entry) error {
 	// 3) Encoded Entry message.
 
 	body := bufPool.Get().(*proto.Buffer)
+	defer bufPool.Put(body)
 	if err := body.Marshal(pb); err != nil {
 		return fmt.Errorf("Unable to marshal message for session recording: %v", err)
 	}
@@ -111,11 +112,13 @@ func recordMessage(opcode session.Kind, pb *session.Entry) error {
 	}
 
 	hdr := bufPool.Get().(*proto.Buffer)
+	defer bufPool.Put(hdr)
 	if err := hdr.Marshal(eh); err != nil {
 		return fmt.Errorf("Unable to marshal message header for session recording: %v", err)
 	}
 
 	l := bufPool.Get().(*proto.Buffer)
+	defer bufPool.Put(l)
 	if err := l.EncodeVarint(uint64(len(hdr.Bytes()))); err != nil {
 		return fmt.Errorf("Unable to write entry header length: %v", err)
 	}

-- 
To stop receiving notification emails like this one, please contact
['"commits@beam.apache.org" <co...@beam.apache.org>'].