Skip to content

Commit b6b24f9

Browse files
committed
Allocate connRows on demand instead of preallocating in bulk
The 64 element preallocatedRows may be pinning memory from previous queries. See #1127
1 parent 1e565b0 commit b6b24f9

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

conn.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,8 @@ type Conn struct {
7373

7474
connInfo *pgtype.ConnInfo
7575

76-
wbuf []byte
77-
preallocatedRows []connRows
78-
eqb extendedQueryBuilder
76+
wbuf []byte
77+
eqb extendedQueryBuilder
7978
}
8079

8180
// 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
513512
}
514513

515514
func (c *Conn) getRows(ctx context.Context, sql string, args []interface{}) *connRows {
516-
if len(c.preallocatedRows) == 0 {
517-
c.preallocatedRows = make([]connRows, 64)
518-
}
519-
520-
r := &c.preallocatedRows[len(c.preallocatedRows)-1]
521-
c.preallocatedRows = c.preallocatedRows[0 : len(c.preallocatedRows)-1]
515+
r := &connRows{}
522516

523517
r.ctx = ctx
524518
r.logger = c

0 commit comments

Comments
 (0)