Memory/Goroutine leak in driver

It looks like the driver is steadily leaking goroutines and memory. The following code demonstrates this. The number of goroutines steadily increases as does the memory, simply by holding an open bucket

package main

import (

func main() {
	bucketName := "test"

	cluster, err := gocb.Connect("couchbase://localhost:8091")
	if err != nil {

	bucket, err := cluster.OpenBucket(bucketName, "")
	if err != nil {

	println("Connected to bucket %s", bucket)

	var memStats runtime.MemStats

	for {
		println(fmt.Sprintf("Number of running goroutines: %d", runtime.NumGoroutine()))

		println(fmt.Sprintf("Allocated memory still in use: %dk", memStats.Alloc/1024))

		println("\n\nDump >>>>>>>>>>>>>>>>>>>>>>")
		pprof.Lookup("goroutine").WriteTo(os.Stdout, 1)

		time.Sleep(5 * time.Second)


Running the code shows that the goroutines are accumulating here:*memdQueue).drainTillSignal+0x13c

The issues are disabled for the driver repo; is this the right channel to raise this problem?

Hey cholick,

The best place to log issues is on our bug tracker here:

I am curious whether you have attempted to run this code with the logger enabled to see if there is any strange behaviour happening internally? You can see how to do that here:

Cheers, Brett

I’ve created a ticket:

(Formatting with code tags failed and I couldn’t seem to re-edit, so apologies).

The debug output wasn’t enlightening, but might be to someone more familiar with the driver