From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22052 invoked by alias); 21 May 2017 07:28:33 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 41131 Received: (qmail 642 invoked from network); 21 May 2017 07:28:33 -0000 X-Qmail-Scanner-Diagnostics: from aok120.rev.netart.pl by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(85.128.245.120):SA:0(0.0/5.0):. Processed in 2.130151 secs); 21 May 2017 07:28:33 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: psprint@zdharma.org X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at zdharma.org does not designate permitted sender hosts) X-Virus-Scanned: by amavisd-new using ClamAV (2) Date: Sun, 21 May 2017 09:28:19 +0200 From: Sebastian Gniazdowski To: zsh-workers@zsh.org Message-ID: Subject: High memory usage on // substitution in one situation, normal usage in other X-Mailer: Airmail (231) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Hello, following will cause like 55 GB of VIRT memory usage (process will be killed), having RES memory at 1.8 MB, which roughly equals to ${#__text}. local -A arr2 for (( i=1; i<=200000; i++ )); do arr2[$i]="_"; done elems=( "${(kv@)arr2}" ) __text=${elems[*]} echo ${#__text} 1688894 __text="${__text//(#b)([^$'\03'-$'\07'$'\013'-$'\014'$'\016'-$'\031'$'0\037']##)/${(q)match[1]}}" Follwing will work smoothly: arr=( ${(s::)${(r:900000::_:)empty}} ) __text=${arr[*]} echo ${#__text} 1799999 __text="${__text//(#b)([^$'\03'-$'\07'$'\013'-$'\014'$'\016'-$'\031'$'0\037']##)/${(q)match[1]}}" I wonder why there is a difference between those two scenarios, why VIRT raises and RES doesn't, and why VIRT rise happens? -- Sebastian Gniazdowski psprint /at/ zdharma.org