mirror of https://github.com/jackc/pgx.git
Allocate connRows on demand instead of preallocating in bulk
The 64 element preallocatedRows may be pinning memory from previous queries. See https://github.com/jackc/pgx/issues/1127pull/1160/head
parent
1e565b0d44
commit
b6b24f9e8a
12
conn.go
12
conn.go
|
@ -73,9 +73,8 @@ type Conn struct {
|
|||
|
||||
connInfo *pgtype.ConnInfo
|
||||
|
||||
wbuf []byte
|
||||
preallocatedRows []connRows
|
||||
eqb extendedQueryBuilder
|
||||
wbuf []byte
|
||||
eqb extendedQueryBuilder
|
||||
}
|
||||
|
||||
// Identifier a PostgreSQL identifier or name. Identifiers can be composed of
|
||||
|
@ -513,12 +512,7 @@ func (c *Conn) execPrepared(ctx context.Context, sd *pgconn.StatementDescription
|
|||
}
|
||||
|
||||
func (c *Conn) getRows(ctx context.Context, sql string, args []interface{}) *connRows {
|
||||
if len(c.preallocatedRows) == 0 {
|
||||
c.preallocatedRows = make([]connRows, 64)
|
||||
}
|
||||
|
||||
r := &c.preallocatedRows[len(c.preallocatedRows)-1]
|
||||
c.preallocatedRows = c.preallocatedRows[0 : len(c.preallocatedRows)-1]
|
||||
r := &connRows{}
|
||||
|
||||
r.ctx = ctx
|
||||
r.logger = c
|
||||
|
|
Loading…
Reference in New Issue