[Newbie Question] why does the amount of memory that my code uses keeps going up?

i found out about this while i was checking a larger code of mine, at first i thought that i might not be disposing of a variable or something properly.
so i tested it with this simple code.

private async void Button_Click(object sender, RoutedEventArgs e) { string result; using (var client = new HttpClient()) { result = await client.GetStringAsync("http://ift.tt/1NHBN92;); } txtResult.Text = result.Length.ToString(); } 

the first run the memory usage is: 10,136K first click and it goes up to: 14,912K after a couple of clicks it goes to 17,488K
am i making a mistake here or is this simple code really taking more and more memory every time it is being run? (i must add that same thing was happening when i used just a simple string and put it in a textbox but memory usage change was not that big to be easily noticeable, so i changed the code to make it bigger and more noticeable)
an screenshot with the task manager

by pooya87 via /r/csharp

Leave a Reply