Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

huge memory leak with prepared statements #170

Closed
volkmarbuehringer opened this issue Mar 9, 2017 · 6 comments
Closed

huge memory leak with prepared statements #170

volkmarbuehringer opened this issue Mar 9, 2017 · 6 comments

Comments

@volkmarbuehringer
Copy link

my program runs with postgres-driver with prepared statements and a footprint of 8 MB
(standard database/sql without any other libraries )

( db.Prepare and then execute stmt.Query very often )

after switching to oracle it has a huge memory leak

without prepared statements it runs fine on oracle ( db.Query )

are prepared statements not supported ?

Another issue is with "insert into returning "
with postgres I execute this Statement with Query and fetch the returned data

with your driver I need to execute with Exec (and additional binds ) and I don't know how to get the returned data

(always database/sql standard library )

@tgulacsi
Copy link
Collaborator

What do you mean by "huge memory leak"? As in #160, ten times the memory of PostgreSQL is not uncommon.

Do you close the prepared statements?

On return: Oracle supports returning only one record, the specified fields. What do you try precisely?

@volkmarbuehringer
Copy link
Author

it is exhausting memory very fast ( 8GB )
1 prepare and many executions of the same statement (works fine with postgres )

therefore I try to work with your driver directly in your style if postgres style doesn't work

@volkmarbuehringer
Copy link
Author

this is an example:

func (m *SQLStatement) SelectID(tab string, id int) (rows *sql.Rows, err error) {
if m.sqlID == nil {
sqls := fmt.Sprintf("select %s from %s where %s %s order by %s", strings.Join(m.ColumnsAllType, ","), tab, m.PK[0], EqBindVar+"1", strings.Join(m.PK, ","))
if m.sqlID, err = DB.Prepare(sqls); err != nil {
return
}
}
rows, err = m.sqlID.Query(id)

return

@tgulacsi
Copy link
Collaborator

tgulacsi commented Mar 10, 2017 via email

@volkmarbuehringer
Copy link
Author

the rows are closed every time after fetch
func (m *SQLStatement) Fetcher(rows *sql.Rows) (gesamte RowMaps, err error) {
defer rows.Close()

the statement is never closed because it is waiting for executions until end ( which works in postgres )

@tgulacsi
Copy link
Collaborator

Please Close the statement.
(I do use Prepare and Query in a for cycle, but haven't met with such behaviour yet).

Do you SELECT DATE typed columns?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants