Created
October 4, 2013 14:26
-
-
Save aliostad/6826806 to your computer and use it in GitHub Desktop.
Not disposing MemoryCache results in memory leak
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
for (int i = 0; i < 1000000000; i++) | |
{ | |
var memoryCache = new MemoryCache("sdf"); // leads to memory leak!!! | |
// WHILE THIS ONE DOES NOT | |
// var memoryStream = new MemoryStream(new byte[100000]); | |
Thread.Sleep(1); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Shouldn't you use MemoryCache.Default?