开发者

Garbage collection of pagecontext attributes java

Consider,

pageContext.setAttribute("name", new String("Shal"));
String name1= new String("Jason");
pageContext.setAttribute("Alternate Name", name1));

how the memory is allocated for the above two attributes,how and when that memory allocated will be recovered. Wha开发者_C百科t is the best practice to follow


Like all other java objects, they will be allocated on the heap, and garbage collected (a) when they are no longer reachable, and (b) when the garbage collector damn well feels like it.

Page-scoped attributes are no longer reachable when the page finishes executing, i.e. when the JSP has finished rendering, unless, of course, something else in the VM has another reference to them.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜