when you connect by ssh. it works fine. but doesn’t work with sftp ?

check your ~user/.bashrc or ~user/.profile or ~user/.cshrc anything related with your environment.

remove the echo from above files.

addons: check free memory on Solaris without top

vmstat 1 2 | tail -1 | awk '{printf "%d%s\n", ($5*4)/1024, "MB" }'