Wicket, page stack, and memory usage

谁都会走 提交于 2020-01-12 04:04:31

问题


A Wicket application serializes and caches all pages to support stateful components, as well as for supporting the back button, among other possible reasons. I have an application which uses setResponsePage to navigate from screen to screen. Over a pretty short amount of time the session gets rather large because all of the prior pages are stored in the session. For the most part, I only need the session to contain the current page, for obvious reasons, and perhaps the last 2 or 3 pages to allow easy navigation using the browser's back button.

Can I force a page to expire after I have navigated away from it and I know that I don't want to use to back button to that version of the page? More generally what is the recommended way to deal with session growth in Wicket?


回答1:


http://apache-wicket.1842946.n4.nabble.com/Wicket-Session-grows-too-big-real-fast-td1875816.html

If you use loads of domain objects on your page, which are eventually tightly coupled to other domain objects, be sure to avoid serialization for these!

Have a look at LoadableDetachableModel for wrapping domaing objects DataView and IDataProvider for displaying list of domain objects

Thou shalt not stuff domain objects into instance variables of components. Thou shalt not make domain object references final in order to use them in anonymous subclasses. Thou shalt not pass a mere List of domain objects to a ListView.

Perhaps, when subclassing WbeRequestCycle in your Application class, you might gain control of a page's lifetime in the pagemap... haven't tried it, though




回答2:


In order to avoid Session choke due to continuous stacking of byte-stream due to serialization in a session and memory usage piling , you can use detachable models by using hooks to arrange for their own storage and restoration at the beginning of each request cycle , this way you have complete control over models containing byte-stream of pages not required in the session or navigable through 'Back' button.



来源:https://stackoverflow.com/questions/281475/wicket-page-stack-and-memory-usage

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!