Skip to content

memory leak? #833

@realjimmy

Description

@realjimmy

hi, my English is not very good, but I try to describe it as clearly as possible.
I think the “conn = p.newConnection(k, s, ts)” should be placed after checking conn2. If Conn2 is not nil and Conn is taken out but not put into Streampool.conns, it will not be flushed by assembler.FlushOlderThan, and it will not be garbage collected and leak memory due to the addition of put it into streampool.all
Please forgive me if I am wrong.

func (p *StreamPool) getConnection(k key, end bool, ts time.Time) *connection {
	p.mu.RLock()
	conn := p.conns[k]
	p.mu.RUnlock()
	if end || conn != nil {
		return conn
	}
	s := p.factory.New(k[0], k[1])
	p.mu.Lock()
	conn = p.newConnection(k, s, ts)  //if conn2 is not nil, I think it will memory leak.
	if conn2 := p.conns[k]; conn2 != nil {
		p.mu.Unlock()
		return conn2
	}
	p.conns[k] = conn
	p.mu.Unlock()
	return conn
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions