提交 08efdf5d 编写于 作者: J Jesse Glick

[JENKINS-16341] Amelioration of memory leak by at least interning some heavily redundant strings.

上级 2eed671b
......@@ -55,6 +55,9 @@ Upcoming changes</a>
<!-- Record your changes in the trunk here. -->
<div id="trunk" style="display:none"><!--=TRUNK-BEGIN=-->
<ul class=image>
<li class=bug>
Reduced size of memory leak in render-on-demand functionality used e.g. in configuration pages.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-16341">issue 16341</a>)
<li class=bug>
Improved logging and error output from SSHD in Jenkins.
</ul>
......
......@@ -25,15 +25,12 @@ package hudson.widgets;
import hudson.Util;
import hudson.model.Descriptor;
import hudson.model.DescriptorByNameOwner;
import hudson.util.IOException2;
import hudson.util.PackedMap;
import org.apache.commons.jelly.JellyContext;
import org.apache.commons.jelly.JellyTagException;
import org.apache.commons.jelly.Script;
import org.kohsuke.stapler.Ancestor;
import org.kohsuke.stapler.HttpResponse;
import org.kohsuke.stapler.Stapler;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
import org.kohsuke.stapler.bind.JavaScriptMethod;
......@@ -64,7 +61,7 @@ public class RenderOnDemandClosure {
private final Map<String,Object> variables;
private final String currentDescriptorByNameUrl;
private final Set<String> adjuncts;
private final String[] adjuncts;
public RenderOnDemandClosure(JellyContext context, String attributesToCapture) {
List<Script> bodyStack = new ArrayList<Script>();
......@@ -77,14 +74,19 @@ public class RenderOnDemandClosure {
Map<String,Object> variables = new HashMap<String, Object>();
for (String v : Util.fixNull(attributesToCapture).split(","))
variables.put(v,context.getVariable(v));
variables.put(v.intern(),context.getVariable(v));
// capture the current base of context for descriptors
currentDescriptorByNameUrl = Descriptor.getCurrentDescriptorByNameUrl();
this.variables = PackedMap.of(variables);
this.adjuncts = AdjunctsInPage.get().getIncluded();
Set<String> _adjuncts = AdjunctsInPage.get().getIncluded();
this.adjuncts = new String[_adjuncts.size()];
int i = 0;
for (String adjunct : _adjuncts) {
this.adjuncts[i++] = adjunct.intern();
}
}
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册