Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3ac7844

Browse files
Free large cached payloads. Fixes #1587
If the ServerSession's payload cache has grown larger than the maximum size of a single packet, free it when the session is returned to the pool so that the memory can be reclaimed.
1 parent b71eb01 commit 3ac7844

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

‎src/MySqlConnector/Core/ServerSession.cs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ public ValueTask ReturnToPoolAsync(IOBehavior ioBehavior, MySqlConnection? ownin
7474
LastReturnedTimestamp = Stopwatch.GetTimestamp();
7575
if (Pool is null)
7676
return default;
77+
78+
// if the payload cache is too large, discard it rather than keeping it alive in the pool; see https://github.com/mysql-net/MySqlConnector/issues/1587
79+
if (m_payloadCache.Array?.Length > ProtocolUtility.MaxPacketSize + 1)
80+
m_payloadCache.ArraySegment = default;
81+
7782
MetricsReporter.RecordUseTime(Pool, Utility.GetElapsedSeconds(LastLeasedTimestamp, LastReturnedTimestamp));
7883
LastLeasedTimestamp = 0;
7984
return Pool.ReturnAsync(ioBehavior, this);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /