Windows Phone Mango - 内存限制 (6 MB) 问题
根据文档,后台任务不能使用超过 6 MB 的内存。我运行后台任务时没有任何代码,如下所示:
protected override void OnInvoke(ScheduledTask task)
{
Debug.WriteLine("Available Memory: " + (DeviceStatus.ApplicationMemoryUsageLimit - DeviceStatus.ApplicationCurrentMemoryUsage).ToString());
Debug.WriteLine("Peak Memory: " + DeviceStatus.ApplicationPeakMemoryUsage.ToString());
NotifyComplete();
}
该代码不包含任何逻辑。只需向输出窗口写入有关可用内存的信息。
以下是上面的输出:
可用内存:1863680
Peak Memory: 4435968
我想知道的是,在不编写任何代码或为对象分配内存的情况下,我的 4435968 字节内存是如何使用的? 如果在不编写代码的情况下使用了 4435968 字节,那么我可以用剩余的 1863680 字节做什么?
As per documentation, background task cannot use more than 6 MB of memory. I ran background task without any code as follows:
protected override void OnInvoke(ScheduledTask task)
{
Debug.WriteLine("Available Memory: " + (DeviceStatus.ApplicationMemoryUsageLimit - DeviceStatus.ApplicationCurrentMemoryUsage).ToString());
Debug.WriteLine("Peak Memory: " + DeviceStatus.ApplicationPeakMemoryUsage.ToString());
NotifyComplete();
}
The code does not contain any logic. Just writing to output window about available memory.
Following is the output of the above:
Available Memory: 1863680
Peak Memory: 4435968
What I am wondering is, without writing any code or allocating memory to object, how is my 4435968 bytes of memory is used? If 4435968 bytes are used without writing code, what will I be able to do with remaining 1863680 bytes?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该考虑后台代理是一段代码,与应用程序的其余部分 100% 分离。
因此,当您不在调试模式下测试它时,即应用程序实际运行的情况下,它不会使用约 4mb 的内存。
你显然担心太多了。如果您甚至接近达到PeriodicAgent 的内存限制,那么我强烈怀疑您正在做一些适合后台任务的事情。
You should consider that the background agent is a single piece of code, that's 100% separated from the rest of your application.
So when you're not testing it in a debug mode, where the application is actually running, it won't be using ~4mb of memory.
You clearly worry to much. If you're even remotely near of hitting the memory limit for a PeriodicAgent, then I strongly doubt you're doing something that's suitable for a background task.