这是什么原因内存问题? [英] What could cause this memory issue?

查看:189
本文介绍了这是什么原因内存问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个应用程序的Windows 8手机,而我有一个内存泄漏问题。但首先,一些背景。该应用的工作原理(不幸)使用化网页浏览器的网页。该页面是有很多涉及的javascript相当复杂的。

I'm working on an app for windows phone 8, and I'm having a memory leak problem. But first some background. The app works (unfortunately) using WebBrowsers as pages. The pages are pretty complex with a lot of javascript involved.

应用程序的本地部分,C#编写的,是负责做与JavaScript的一些简单的沟通(如本机是的JavaScript与服务器通信),使网页过渡,跟踪,持久性等,全部以独特的PhoneApplicationPage做动画的委托。

The native part of the app, written in c#, is responsible for doing some simple communication with the javascript(e.g. native is a delegate for the javascript to communicate with a server), make animation for page transition, tracking, persistance, etc. All is done in a unique PhoneApplicationPage.

在我对内存不足异常有些崩溃了,我开始分析应用程序。我可以看到化网页浏览器,这是该应用程序的重要组成部分,正在正确处置。
,而我看到的问题是,内存继续增加。更糟的是,我从探查小反馈。据我了解,剖析图说,有一个很大的问题,而探查数字说有没有问题......

After I had some crashes for out of memory exceptions, I started profiling the app. I can see that the WebBrowsers, which are the big part of the the app, are being disposed correctly. But the problem I'm seeing is that memory continues to increase. What's worse, I have little feedback from the profiler. From what I understand, the profiler graph says there is a big problem, while the profiler numbers say there's no problem at all...

请注意:步骤表示导航从web浏览器到另一个web浏览器。尖峰是由两个控件之间的动画创建(我想)。在我的图像中选择的跨度,我在做一个导航前进档和一个落后的有5化网页浏览器(2对于那些总是有菜单功能,用于索引页的页面,我从导航和1最大信号,1,1该页面我浏览)。在每一个导航探查器显示正确的数字化网页浏览器的:向后浏览后向前导航,后4 5

Note: the step represents a navigation from a WebBrowser to another WebBrowser. The spike is created (I suppose) by the animation between the two controls. In the span I've selected in the image, I was doing a navigation forward and one backward having a maxium of 5 WebBrowsers (2 for menus that are always there, 1 for the index page, 1 for the page I navigate from and 1 for the page I navigate to). At every navigation the profiler shows the correct number of WebBrowsers: 5 after navigating forward, 4 after navigating backward.

注2:我添加红线更清楚的记忆在时间跨度是往上走

Note 2: I have added the red line to make clearer that the memory is going up in that span of time

你可以从图像

的内存使用量是相当大的,但数字说这是低,在时间跨度,保留分配比什么时候开始下...

As you can see from the image the memory usage is pretty big but the numbers say it's low and in that span of time, retained allocation is lower than when it started...

我希望我已经包含足够的信息。我想什么可能导致此问题的一些想法。我的想法至今都:

I hope I've included enough information. I want some ideas on what could cause this problem. My ideas so far are:

在web浏览器的JavaScript -the做得不对(如不清洗一些事件处理程序)。即使是这种情况,当它被破坏,不应该web浏览器释放存储器

-the javascript in the WebBrowser is doing something wrong (e.g. not cleaning some event handler). Even if this is the case, shouldn't the WebBrowser release the memory when it is destroyed?

- 使用一个独特的PhoneApplicationPage东西恶是不应该被完成?,并改变其结构可能会导致此

-using a unique PhoneApplicationPage is something evil that is not supposed to be done, and changing its structure may cause this.

- 其他

另一个问题:为什么图秀内存使用正确的金额,而数量不?

Another question: why does the graph show the correct amount of memory use while the number doesn't?

如果您需要有关分析器的详细信息,请与我将发布他们的明天。

If you need more info about the profiler, ask and I will post them tomorrow.

推荐答案

确定后大量调查,我终于能够找到泄漏。
泄漏是由WebBrowser控件本身,这似乎有当您从面板中删除它并未被删除一些事件处理程序创建的。事实上泄漏是可重复的按下列步骤进行:

Ok after a lot of investigation I finally was able to find the leak. the leak is created by the WebBrowser control itself which seems to have some event handler that are not removed when you remove it from a Panel. In fact the leak is reproducible by following these steps:


  1. 创建一个新的web浏览器

  2. 添加它到面板或任何

  3. 导航到一个页面,用又大又重

  4. 图像某处点击浏览器的空白(敲击在图像上似乎不会造成泄漏)

  5. 删除并收集浏览器

  6. 从1

  7. 复读
  1. Create a new WebBrowser
  2. Add it to a Panel or whatever
  3. Navigate to a page, with an image which is big and heavy
  4. Tap somewhere in the blank space of the browser(tapping on the image seems to not create the leak)
  5. remove and collect the browser
  6. repeat from 1

在每次迭代图像的记忆是永远不会收集和存储不断增长。

at every iteration the memory of the image is never collected and the memory continue to grow.

一票微软已经发出。

问题是用化网页浏览器

这篇关于这是什么原因内存问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆