検討:spring mvcでredirectがメモリ漏れ?


外国人にいるhttp://vard-lokkur.blogspot.com/2012/12/springs-web-mvc-redirect-to-memory-leak.html本文では、spring mvc 3と以前のバージョンが存在する可能性があることを発見しました.
redirectによるメモリ漏洩の問題.例は次のとおりです.

@RequestMapping(method = RequestMethod.POST)
public String onPost(...) {
    ...
    return "redirect:form.html?entityId=" + entityId;
}



  You may start from reading Resolving views in Spring Framework documentation, and then take a closer look at the source code of AbstractCachingViewResolver, which is base class for many different View Resolvers in Spring, including: JSP, FreeMarker, Velocity, Jasper Reports, Tiles and XSLT view resolvers.
When resolveViewName method is called on AbstractCachingViewResolver it uses HashMap based view cache to speed up view resolving in the future calls, and cache key is by default created using view name and current locale.
Now to the clue
- when you use the above method of redirecting, Spring Framework uses the whole String returned from your controller's method as the view name, including all parameters included in the target URL. Each time you perform the redirect, the parameters may vary, thus such a redirect will leave one additional entry in view cache of  AbstractCachingViewResolver, causing memory leak.
    彼は、この形式であれば、何度も実行すると(彼は7000回以上実行した)、JVMサイズの設定の問題を見てメモリが漏洩する可能性があると考えています.理由は、AbstractCachingViewResolver、このコードは多くのビュー解析の親であると分析しています.
resolveViewNameメソッドがAbstractCachingViewResolverを呼び出す場合、hashmapが使用されます.
キャッシュは加速し、keyはviewnameと現在のlocale eをデフォルトで使用し、springは呼び出し
redirectこの場合、controllerメソッドから返される文字列全体をview nameとして使用し、あなたのターゲットurlを含めてmemory leakを招いた(しかしなぜですか?原文の著者は具体的に分析していないようです)
      作者はまだhttps://jira.springsource.org/browse/SPR-10065jiraの説明を開き、
興味のある読者は見てみましょう.彼がテストしたDEMOの例は次のとおりです.
https://github.com/vardlokkur/webapp-02ダウンロードできます.
   残念ながら私は自分の机械の上で、chromeの下で7000回以上実行して、问题があることを発见していないで、しかしIEの下で1040まで実行します
回、間違いなく報告しましたが、やめました.おかしいですね.検討してみてください.