You need to distinguish between allocated and working-set RAM. It's easy to eat up memory in bash:
A="0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
for power in $(seq 8); do
A="${A}${A}"
done
but unless the script churns through the data frequently then those pages of memory are good candidates to be swapped out.