Closed nenadnoveljic closed 1 year ago
But this (without jmoiron/sqlx) doesn't leak:
func main() {
databaseUrl := go_ora.BuildUrl(HOST, PORT, SERVICE_NAME, USER, PASSWORD, map[string]string{})
db, err := sqlx.Open("oracle", databaseUrl)
conn, err := go_ora.NewConnection(databaseUrl)
if err != nil {
log.Fatalf("failed to connect %s", err)
}
err = conn.Open()
if err != nil {
log.Fatalf("failed to open %s", err)
}
defer func() {
err = conn.Close()
if err != nil {
fmt.Println("Can't close 2nd connection: ", err)
}
}()
if err != nil {
log.Fatalf("failed to connect %s", err)
}
for i := 0; i < 10; i++ {
sqlText := `BEGIN SELECT to_clob('A') s INTO :1 FROM dual; END;`
var data go_ora.Clob
_, err = conn.Exec(sqlText, go_ora.Out{Dest: &data, Size: 100000})
if err != nil {
log.Fatalf("failed to execute %s", err)
}
//fmt.Printf("data: %s \n", data.String)
p, err := getMyUsedPGA(db)
if err != nil {
log.Fatalf("failed to get memory %s", err)
}
fmt.Printf("PGA [bytes]: %f \n", p)
}
}
go run main.go
data: A
PGA [bytes]: 2546447.000000
data: A
PGA [bytes]: 2538063.000000
data: A
PGA [bytes]: 2538063.000000
data: A
PGA [bytes]: 2538063.000000
data: A
PGA [bytes]: 2538063.000000
data: A
PGA [bytes]: 2538063.000000
data: A
PGA [bytes]: 2538063.000000
data: A
PGA [bytes]: 2538063.000000
data: A
PGA [bytes]: 2538063.000000
data: A
PGA [bytes]: 2538063.000000
The problem appears when
go-ora
is used withjmoiron/sqlx
. The problem doesn't appear withgodror
.Test case:
Output: