我遇到了一个问题,我在 Windows Phone 8 应用程序中的部分代码正在调用System.OutOfMemoryException
. 我想用它Process.GetCurrentProcess();
来检查可用内存,但由于它似乎不存在于System.Diagnostics
命名空间中,所以无法找到它。
我是开始尝试直接调用 Windows API 的唯一选择吗(假设这甚至是可能的)?我想要获得当前进程的真正原因是确定我的应用程序的总可用内存。
任何帮助表示赞赏。
编辑:
这是代码
public async static Task<T> InvokeServiceAsync<T>(string BaseAddress, string Path, params object[] ParamArray)
{
HttpClient client = new HttpClient();
client.BaseAddress = new Uri(BaseAddress);
HttpResponseMessage response = await client.GetAsync(string.Format("{0}{1}", Path, MvcUtilities.BuildWebApiRequest(ParamArray)));
response.EnsureSuccessStatusCode();
T result = await response.Content.ReadAsAsync<T>(); //Out of memory exception
return result;
}