0

I'm using AbstractAjaxWicketBehavior in my Wicket application and it seems to have a descending performance over time when more AJAX calls appear. When a page is refreshed without AJAX, the performance is fine again. I would like to know if this is a normal thing or can be a memory leak of some kind present? I can't simply attach the code as it's spread over more classes and it would require too much effort to understand, but in short I want to do this:

  1. create and start the timer
  2. repeat some code 10x
  3. stop the timer
  4. set some values to attributes
  5. ajax refresh (causes show/hide of some components)

and do the same again (hypotetically infinite times).

Every repetition of this flow is slower even though I use constant updating interval of 100ms.

As the timer is a behavior and does not allow to be restarted or reused, it is created every time as a new instance and attached to the Form component.

The timer looks like this:

static int count = 0
new AbstractAjaxTimerBehavior(Duration.milliseconds(100)) {
 // do some code
 count++
 if(count == 10) {
  stop();
  // do some code
 } 
}

This behavior is attached to a Form inside a Panel and upon a click on an AjaxLink the Form is refreshed (added to AjaxRequestTarget). Every time I remove the old timer from the Form component before adding the new behavior.

Everything works fine, but every repetition of this procedure runs slower (The first one is perfect, the second one is also around 100ms, but then it gets slower (after 10 or 15 repetitions, the refresh interval is about 1 second) and all other AJAX calls in the app also go significantly slower), so I suspect there is a memory leak... any obvious reasons? Or any ways how to make a wicket timer better for my purpose? Any advice appreciated. Thanks.

4

1 回答 1

2

我们的 wicket 应用程序也往往会随着每个 AJAX 请求而变慢。我不确定这是否是完全相同的问题,或者它是否与 AjaxTimerBehavior 特别相关,但是:

我们发现造成这种情况的一个原因是由于 HTML 替换而发生的浏览器中的伪泄漏。显然,浏览器在重新加载页面之前无法释放内存。

您可以使用任务管理器(或其他工具)监控浏览器内存,并观察每个 AJAX 请求的内存增加以及它如何在整个页面重新加载 (F5) 时缓解。尤其是在 IE 中。

不过,我们用 AJAX 请求替换了很多 HTML。

于 2012-06-28T08:29:43.697 回答