You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Jens Geyer (JIRA)" <ji...@apache.org> on 2013/11/28 21:21:35 UTC
[jira] [Comment Edited] (THRIFT-2275) Fix memory leak in golang
compact_protocol.
[ https://issues.apache.org/jira/browse/THRIFT-2275?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13835064#comment-13835064 ]
Jens Geyer edited comment on THRIFT-2275 at 11/28/13 8:20 PM:
--------------------------------------------------------------
Thanks [~wizardcypress] for catching and fixing this, committed.
Next time, please add a *patch +file+* instead of copying the diff into the text. This time, it was an very simple one-liner change, but that's not always the case.
was (Author: jensg):
Thanks [~wizardcypress] for catching and fixing this, committed.
Next time, please add a *patch +file+* instead of copying the diff into the text. This time, it was an very simple onl-liner change, but that's not always the case.
> Fix memory leak in golang compact_protocol.
> -------------------------------------------
>
> Key: THRIFT-2275
> URL: https://issues.apache.org/jira/browse/THRIFT-2275
> Project: Thrift
> Issue Type: Bug
> Components: Go - Library
> Environment: os x 10.9
> Reporter: bolin huang
> Assignee: Jens Geyer
> Fix For: 0.9.2
>
>
> After a long time running go program base on compact protocol, I found that the memory is just increase and never drop. After using go tool pprof to check the memory usage, I found in `ReadStructBegin` it push `lastFieldId` to the slice p.lastField. But in `ReadStructEnd`, it just assign the last element in `p.lastField` to `lastFieldId` and do not pop the last element.
> So the length of `p.lastField` is just increasing...
> To fix the bug,we need to pop the last element as the patch shows below:
> diff --git a/lib/go/thrift/compact_protocol.go b/lib/go/thrift/compact_protocol.go
> index 74d36d0..f89fc2f 100644
> --- a/lib/go/thrift/compact_protocol.go
> +++ b/lib/go/thrift/compact_protocol.go
> @@ -352,6 +352,7 @@ func (p *TCompactProtocol) ReadStructBegin() (name string, err error) {
> func (p *TCompactProtocol) ReadStructEnd() error {
> // consume the last field we read off the wire.
> p.lastFieldId = p.lastField[len(p.lastField)-1]
> + p.lastField = p.lastField[:len(p.lastField)-1]
> return nil
> }
--
This message was sent by Atlassian JIRA
(v6.1#6144)