Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
StackExchange.Redis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
StackExchange.Redis
Commits
77a3986a
Commit
77a3986a
authored
Jul 16, 2018
by
Marc Gravell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clarify MuxerIsCollected
parent
7171938d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
15 deletions
+15
-15
GarbageCollectionTests.cs
StackExchange.Redis.Tests/GarbageCollectionTests.cs
+15
-15
No files found.
StackExchange.Redis.Tests/GarbageCollectionTests.cs
View file @
77a3986a
...
...
@@ -12,39 +12,39 @@ public class GarbageCollectionTests : TestBase
private
static
void
ForceGC
()
{
for
(
int
i
=
0
;
i
<
3
;
i
++)
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
GC
.
Collect
(
GC
.
MaxGeneration
,
GCCollectionMode
.
Forced
);
GC
.
WaitForPendingFinalizers
();
}
}
#if DEBUG
[
Fact
]
public
void
MuxerIsCollected
()
{
// first check WeakReference works like we expect
var
obj
=
new
object
();
var
wr
=
new
WeakReference
(
obj
);
obj
=
null
;
ForceGC
();
Assert
.
Null
(
wr
.
Target
);
// this is more nuanced than it looks; multiple sockets with
// async callbacks, plus a heartbeat on a timer
var
muxer
=
Create
();
// deliberately not "using"
muxer
.
GetDatabase
().
Ping
();
// deliberately not "using" - we *want* to leak this
var
muxer
=
Create
();
muxer
.
GetDatabase
().
Ping
();
// smoke-test
ForceGC
();
int
before
=
ConnectionMultiplexer
.
CollectedWithoutDispose
;
wr
=
new
WeakReference
(
muxer
);
#if DEBUG // this counter only exists in debug
int
before
=
ConnectionMultiplexer
.
CollectedWithoutDispose
;
#endif
var
wr
=
new
WeakReference
(
muxer
);
muxer
=
null
;
ForceGC
();
int
after
=
ConnectionMultiplexer
.
CollectedWithoutDispose
;
// should be collectable
Assert
.
Null
(
wr
.
Target
);
#if DEBUG // this counter only exists in debug
int
after
=
ConnectionMultiplexer
.
CollectedWithoutDispose
;
Assert
.
Equal
(
before
+
1
,
after
);
}
#endif
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment