我正在学习正确使用RESTSharp的executeAsync
方法,并且由于不正确地处理RestRequests(可能)而面临内存泄漏:
var client = new RestClient("some_URL");
int count = 99999;
for (int i=0; i < count; i++) {
var request = new RestRequest("some_link", Method.GET);
request.AddParameter("some_param", i.toString());
client.ExecuteAsync(request, response =>
{
some_callback_function(response.content);
request = null;
response = null;
}
}
如果我让这段代码运行,我的应用程序的内存不断增加,似乎没有垃圾回收。
处理ExecuteAsync
的响应并在之后处理对象的正确方法是什么?