Skip to content

fixed memory leak caused by PQprepare#40

Merged
EnriqueL8 merged 2 commits intoKitura:masterfrom
ralischer:master
Mar 5, 2018
Merged

fixed memory leak caused by PQprepare#40
EnriqueL8 merged 2 commits intoKitura:masterfrom
ralischer:master

Conversation

@ralischer
Copy link
Copy Markdown
Contributor

Documentations says: "As with PQexec, the result is normally a PGresult object whose contents indicate server-side success or failure."
This PGresult objects needs to be cleared with PQclear. "Every command result should be freed via PQclear when it is no longer needed."

Documentations says: "As with PQexec, the result is normally a PGresult object whose contents indicate server-side success or failure." 
This PGresult objects needs to be cleared with PQclear. "Every command result should be freed via PQclear when it is no longer needed."
@ralischer
Copy link
Copy Markdown
Contributor Author

ralischer commented Dec 21, 2017

I think there is another memory leak when result != nil AND PQresultStatus(result) != PGRES_COMMAND_OK, I would fixed it but I don't know anything about your coding conventions and result isn't accessible inside the guard statement

Edit: never mind solved it like in executeTransaction

@codecov-io
Copy link
Copy Markdown

Codecov Report

Merging #40 into master will decrease coverage by 0.04%.
The diff coverage is 60%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #40      +/-   ##
==========================================
- Coverage   73.42%   73.37%   -0.05%     
==========================================
  Files           3        3              
  Lines         444      447       +3     
==========================================
+ Hits          326      328       +2     
- Misses        118      119       +1
Flag Coverage Δ
#SwiftKueryPostgreSQL 73.37% <60%> (-0.05%) ⬇️
Impacted Files Coverage Δ
...es/SwiftKueryPostgreSQL/PostgreSQLConnection.swift 60.58% <60%> (+0.07%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 79ff943...47200d0. Read the comment docs.

@EnriqueL8
Copy link
Copy Markdown
Contributor

@tunniclm Should we have a look at this?

@tunniclm
Copy link
Copy Markdown
Collaborator

tunniclm commented Mar 2, 2018

@EnriqueL8 Missed this notification, sorry! Yes, I think this looks important and we should investigate and merge if it looks good.

@EnriqueL8
Copy link
Copy Markdown
Contributor

LGTM, @ianpartridge what do you think?

@ianpartridge
Copy link
Copy Markdown
Contributor

LGTM, merge when you're ready. @EnriqueL8 can you also audit the rest of the codebase for missing calls to PQclear()?

@EnriqueL8
Copy link
Copy Markdown
Contributor

Could do

@EnriqueL8
Copy link
Copy Markdown
Contributor

I believe the three cases (Query, PreparedStatement and Transaction) are now covered:

  • Query uses a helper function to clear the result
  • Transaction calls PQClear directly
  • PrepareStatement is this PR which mimics the Transaction case

@ianpartridge
Copy link
Copy Markdown
Contributor

Cool, thanks. I think this should be tagged as 1.1.1 after merge, can you do this?

@EnriqueL8
Copy link
Copy Markdown
Contributor

okay, merging

@EnriqueL8 EnriqueL8 merged commit 3be53cc into Kitura:master Mar 5, 2018
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

Successfully merging this pull request may close these issues.

5 participants