Skip to content

fix: dispose leaked DbConnection and DbCommand in SQL layer#107

Draft
sylvester-henrique with Copilot wants to merge 2 commits into
masterfrom
copilot/analyze-memory-leaks-dbconnection-dbcommand
Draft

fix: dispose leaked DbConnection and DbCommand in SQL layer#107
sylvester-henrique with Copilot wants to merge 2 commits into
masterfrom
copilot/analyze-memory-leaks-dbconnection-dbcommand

Conversation

Copilot AI commented Mar 13, 2026

Copy link
Copy Markdown
Contributor

Three disposal bugs in Take.Elephant.Sql causing connection/command leaks:

  • DbDataReaderAsyncEnumerator2.MoveNextAsyncDbConnection from factory stored in local variable, never disposed. Added _dbConnection field and disposal in DisposeAsync(), matching the pattern in DbDataReaderAsyncEnumerator.

  • DbConnectionExtensions.ExecuteNonQueryAsync — Returns Task<int> without await, so the using block disposes the DbCommand before the async operation completes. Made method async.

  • DatabaseSchema.AlterTableColumnsAsyncconnection.CreateCommand() in loop body never wrapped in using.


💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.

…2, await DbCommand in ExecuteNonQueryAsync, dispose DbCommand in AlterTableColumnsAsync

Co-authored-by: sylvester-henrique <19980165+sylvester-henrique@users.noreply.github.com>
Copilot AI changed the title [WIP] Analyze memory leaks in DbConnection and DbCommand fix: dispose leaked DbConnection and DbCommand in SQL layer Mar 13, 2026
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.

2 participants