mirror of https://github.com/apache/jmeter.git
Bug 54268 - Improve CPU and memory usage
Factor out code
Bugzilla Id: 54268
git-svn-id: https://svn.apache.org/repos/asf/jmeter/trunk@1451929 13f79535-47bb-0310-9956-ffa450edef68
Former-commit-id: cb248782ed
This commit is contained in:
parent
33f03d24fb
commit
32b51d689e
|
|
@ -164,23 +164,7 @@ public class RegexExtractor extends AbstractScopedTestElement implements PostPro
|
||||||
} catch (MalformedCachePatternException e) {
|
} catch (MalformedCachePatternException e) {
|
||||||
log.error("Error in pattern: " + regex);
|
log.error("Error in pattern: " + regex);
|
||||||
} finally {
|
} finally {
|
||||||
clearMatcherMemory(matcher, pattern);
|
JMeterUtils.clearMatcherMemory(matcher, pattern);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Hack to make matcher clean the two internal buffers it keeps in memory which size is equivalent to
|
|
||||||
* the unzipped page size
|
|
||||||
* @param matcher {@link Perl5Matcher}
|
|
||||||
* @param pattern Pattern
|
|
||||||
*/
|
|
||||||
private final void clearMatcherMemory(Perl5Matcher matcher, Pattern pattern) {
|
|
||||||
try {
|
|
||||||
if(pattern != null) {
|
|
||||||
matcher.matches("", pattern); // $NON-NLS-1$
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
// NOOP
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1309,4 +1309,20 @@ public class JMeterUtils implements UnitTestManager {
|
||||||
System.gc();
|
System.gc();
|
||||||
System.runFinalization();
|
System.runFinalization();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hack to make matcher clean the two internal buffers it keeps in memory which size is equivalent to
|
||||||
|
* the unzipped page size
|
||||||
|
* @param matcher {@link Perl5Matcher}
|
||||||
|
* @param pattern Pattern
|
||||||
|
*/
|
||||||
|
public static final void clearMatcherMemory(Perl5Matcher matcher, Pattern pattern) {
|
||||||
|
try {
|
||||||
|
if(pattern != null) {
|
||||||
|
matcher.matches("", pattern); // $NON-NLS-1$
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
// NOOP
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue