bash's pattern substitution seems to leak some memory.

Solution In Progress - Updated -

Issue

  • The customer found that a bash script increases its memory consumption gradually which uses pattern substitution.
  • Reproducer
  # cat test.sh
  a=00:00
  while :
  do
      b=${a/:/}
  done
  # sh test.sh
  • Actual results
  # ps aux | grep [t]est.sh
  root     21877 78.0  0.1 113900  9084 pts/4    R+   09:49   0:01 sh test.sh
  # ps aux | grep [t]est.sh
  root     21877 93.3  0.1 120044 15268 pts/4    R+   09:49   0:02 sh test.sh
  # ps aux | grep [t]est.sh
  root     21877  105  0.2 126956 22236 pts/4    R+   09:49   0:04 sh test.sh
  # ps aux | grep [t]est.sh
  root     21877 93.3  0.3 133996 29196 pts/4    R+   09:49   0:05 sh test.sh
                           ^^^^^^^^^^^^

Environment

  • Red Hat Enterprise Linux 6
  • Red Hat Enterprise Linux 7
  • bash

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.