zsh-workers
 help / color / mirror / code / Atom feed
From: Sebastian Gniazdowski <psprint@zdharma.org>
To: zsh-workers@zsh.org
Subject: High memory usage on // substitution in one situation, normal usage in other
Date: Sun, 21 May 2017 09:28:19 +0200	[thread overview]
Message-ID: <etPan.59214193.41a7c4c9.6b4c@MacMini.local> (raw)

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


             reply	other threads:[~2017-05-21  7:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-21  7:28 Sebastian Gniazdowski [this message]
2017-05-21 20:03 ` Bart Schaefer
2017-05-21 20:47   ` Re[2]: " Manuel Presnitz
     [not found]   ` <201705212227360937.046E4951@gateway.core.mpy.ch>
2017-05-21 23:43     ` Bart Schaefer
2017-05-22  3:31       ` Sebastian Gniazdowski
2017-05-22  8:50       ` Daniel Shahaf
2017-05-22 15:00         ` Bart Schaefer
2017-05-23 15:33           ` Christian Neukirchen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=etPan.59214193.41a7c4c9.6b4c@MacMini.local \
    --to=psprint@zdharma.org \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).