Garbage collection in bash

Does bash garbage collector do? Can this be controlled with some command line options? I can not find anything online about this.

I have a bash script that works, and within a few days its memory usage is increasing. I want to know where the memory is.

+5
source share
1 answer

Bash does not start the garbage collector as such. Since there is no concept of links in it, there is no need to find data without links. However, free memory is no longer used.

Here's a simple demonstration of memory usage before and after declaring and overwriting a large variable. Memory usage increases up and down:

ps -o rss -p $$
var=$(printf "%s\n" {1..100000})
ps -o rss -p $$
var="smallstring"
ps -o rss -p $$
+6
source

All Articles