Skip to content

Commit eaaac0e

Browse files
committed
fix memory leak on JRuby 1.x and version bump
It seems that on JRuby 1.x (tested jruby-1.7.27), the outer loop when coded as Java forEach causes JRuby to leak some internal state. Specifically the NonBlockingHashMapLong$CHM dominates the memory. See the referenced bug for a reproduction case. The commit changes the outer loop to a standard for loop to avoid this bug. Fixes #135 Fixes #136
1 parent 1acf1b3 commit eaaac0e

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 4.0.3
2+
- Fixed memory leak when run on JRuby 1.x (Logstash 5.x) [#135](https://github.com/logstash-plugins/logstash-filter-grok/issues/135)
3+
14
## 4.0.2
25
- Fixed resource leak where this plugin might get double initialized during plugin reload, leaking a thread + some objects
36

lib/logstash/filters/grok/timeout_enforcer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def stop!
5656

5757
def cancel_timed_out!
5858
now = java.lang.System.nanoTime # save ourselves some nanotime calls
59-
@threads_to_start_time.forEach do |thread, start_time|
59+
@threads_to_start_time.keySet.each do |thread|
6060
# Use compute to lock this value
6161
@threads_to_start_time.computeIfPresent(thread) do |thread, start_time|
6262
if start_time < now && now - start_time > @timeout_nanos

logstash-filter-grok.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Gem::Specification.new do |s|
22

33
s.name = 'logstash-filter-grok'
4-
s.version = '4.0.2'
4+
s.version = '4.0.3'
55
s.licenses = ['Apache License (2.0)']
66
s.summary = "Parses unstructured event data into fields"
77
s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"

0 commit comments

Comments
 (0)