简体   繁体   English

Windows Phone 8中的System.Diagnostics.Process在哪里?

[英]Where is System.Diagnostics.Process in Windows Phone 8?

I have run into a problem where a part of my code in a Windows Phone 8 application is invoking a System.OutOfMemoryException . 我遇到了一个问题,其中Windows Phone 8应用程序中的部分代码正在调用System.OutOfMemoryException I wanted to use Process.GetCurrentProcess(); 我想使用Process.GetCurrentProcess(); to examine available memory but have been unable to find it as it doesn't appear to exist in the System.Diagnostics namespace. 检查可用内存,但由于System.Diagnostics命名空间中似乎不存在而无法找到它。

Is my only option to start trying to call the Windows API directly (assuming that's even possible)? 我是否是开始尝试直接调用Windows API的唯一选择(假设甚至有可能)? My real reason for wanting to get the current process was in determining the total available memory to my application. 我想要获得当前进程的真正原因是确定应用程序的总可用内存。

Any help kindly appreciated. 任何帮助,感激不尽。

EDIT: 编辑:

This is the code 这是代码

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;
}

No, Phone apps can't start processes nor enumerate them. 不,电话应用程序无法启动进程或无法枚举它们。 The winapi loophole is closed as well, enforced by the SDK headers, certification and the sandbox. Winapi漏洞也由SDK标头,证书和沙箱强制关闭。 Even if it were available then it would be very unlikely that code could run in an OOM condition. 即使可用,代码也不太可能在OOM条件下运行。

It is never another process that causes it, Phone runs a virtual memory demand-paged operating system. 永远不会是导致它的其他进程,Phone会运行虚拟内存按需分页的操作系统。 Recovering from OOM is extremely difficult, there's very little point in trying. 从OOM中恢复非常困难,尝试没有什么意义。 You need to make do with less allocations. 您需要减少分配。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM