prestodb/presto-go-client

OOM

Opened this issue · 1 comments

how to free memory shared, waiting for help
image

go tool pprof -alloc_space http://xxxxx:8899/debug/pprof/heap

image

package main

import (
"database/sql"
"fmt"
_ "github.com/prestodb/presto-go-client/presto"
"net/http"
_ "net/http/pprof"
"time"
)

var SerNum int

func ServerNum(app string, dt time.Time) int {

dsn := "http://root@xxxxx:8080?catalog=hive&schema=tds_tmp"
db, err := sql.Open("presto", dsn)
if err != nil {
	fmt.Println(err)
}
defer db.Close()

s := fmt.Sprintf(
	`select  count(ip) from xxx where dt='%s' and  appname='%s'`, dt.Format("20060102"), app)

err = db.QueryRow(s).Scan(&SerNum)

if err != nil {
	fmt.Println(err)
} else {
	return SerNum
}

return 0

}

func main() {

go func() {
	_ = http.ListenAndServe("0.0.0.0:8899", nil)
}()

for i := 0; i < 1000; i++ {
	num := ServerNum("xxx", time.Now())
	fmt.Println(num)
}

}

Cannot spend time troubleshooting this now. If you find something and send a PR we can review.