ASF Bugzilla – Attachment 27497 Details for
Bug 47921
Variables not released for GC after JMeterThread exits.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Fixes the leaks
BUG_47921.patch (text/plain), 2.83 KB, created by
Philippe Mouawad
on 2011-09-14 21:34:38 UTC
(
hide
)
Description:
Fixes the leaks
Filename:
MIME Type:
Creator:
Philippe Mouawad
Created:
2011-09-14 21:34:38 UTC
Size:
2.83 KB
patch
obsolete
>Index: src/core/org/apache/jmeter/threads/JMeterContext.java >=================================================================== >--- src/core/org/apache/jmeter/threads/JMeterContext.java (revision 1166194) >+++ src/core/org/apache/jmeter/threads/JMeterContext.java (working copy) >@@ -65,6 +65,7 @@ > samplingStarted = false; > threadNum = 0; > readBuffer = null; >+ thread = null; > } > > /** >Index: src/core/org/apache/jmeter/threads/JMeterThread.java >=================================================================== >--- src/core/org/apache/jmeter/threads/JMeterThread.java (revision 1166194) >+++ src/core/org/apache/jmeter/threads/JMeterThread.java (working copy) >@@ -20,9 +20,12 @@ > > import java.util.ArrayList; > import java.util.Collection; >+import java.util.HashSet; > import java.util.Iterator; > import java.util.List; > import java.util.ListIterator; >+import java.util.Map; >+import java.util.Set; > > import org.apache.jmeter.assertions.Assertion; > import org.apache.jmeter.assertions.AssertionResult; >@@ -123,6 +126,11 @@ > > private volatile Sampler currentSampler; > >+ /** >+ * Variables backup state at start of run >+ */ >+ private JMeterVariables threadVarsBkp; >+ > public JMeterThread(HashTree test, JMeterThreadMonitor monitor, ListenerNotifier note) { > this.monitor = monitor; > threadVars = new JMeterVariables(); >@@ -302,6 +310,28 @@ > threadFinished(); > monitor.threadFinished(this); // Tell the engine we are done > JMeterContextService.removeContext(); // Remove the ThreadLocal entry >+ clearThreadVars(); >+ } >+ } >+ >+ /** >+ * Clean all variables that have been added by samplers by coming back to initial set >+ */ >+ private void clearThreadVars() { >+ Set<String> keysToKeepSet = new HashSet<String>(); >+ for (Iterator<Map.Entry<String,Object>> iterator = threadVarsBkp.getIterator(); iterator.hasNext();) { >+ keysToKeepSet.add(iterator.next().getKey()); >+ } >+ Set<String> keysToRemoveSet = new HashSet<String>(); >+ for (Iterator<Map.Entry<String,Object>> iterator = threadVars.getIterator(); iterator.hasNext();) { >+ Map.Entry<String,Object> entry = iterator.next(); >+ if(!keysToKeepSet.contains(entry.getKey())) >+ { >+ keysToRemoveSet.add(entry.getKey()); >+ } >+ } >+ for (String key : keysToRemoveSet) { >+ threadVars.remove(key); > } > } > >@@ -473,6 +503,8 @@ > * > */ > private void initRun(JMeterContext threadContext) { >+ threadVarsBkp = new JMeterVariables(); >+ threadVarsBkp.putAll(threadVars); > threadContext.setVariables(threadVars); > threadContext.setThreadNum(getThreadNum()); > threadContext.getVariables().put(LAST_SAMPLE_OK, TRUE);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 47921
:
27497
|
27498
|
27499