From: <tomas@tuxteam.de>
To: Konstantin Kharlamov <hi-angel@yandex.ru>
Cc: libc-help@sourceware.org
Subject: Re: Q: System behaviour in out of memory situation
Date: Mon, 5 Jun 2023 06:41:55 +0200 [thread overview]
Message-ID: <ZH1nk2JiiOGA9isg@tuxteam.de> (raw)
In-Reply-To: <af7ffa95539f1028f628aa54f67d869d58c681ff.camel@yandex.ru>
[-- Attachment #1: Type: text/plain, Size: 1329 bytes --]
On Mon, Jun 05, 2023 at 03:28:00AM +0300, Konstantin Kharlamov wrote:
> Hi, just 2 theoretic questions:
>
> 1. I know that calling malloc() only allocates a virtual memory, not a real one. It's kind of memory you can allocate Terabytes of, which some apps do (e.g. on my system electron has 1.1T allocated). It will only turn into a real memory by the kernel upon the app accessing it. But then, assuming OOM-killer is disabled, what happens if I try to access such virtual memory thus forcing it to turn into a real one, but the system is out of real memory ATM?
> 2. Is it unrealistic to expect ENOMEM from `malloc()`? That is because α) most systems have OOM-killer enabled, so instead of ENOMEM some app will get killed β) In absence of OOM-killer you'll get virtual memory successfully allocated, which returns us to 1.
>
> P.S.: I asked 1st question on #glibc OFTC on Saturday as well, but got no reply still. So decided to give a try to the ML.
I guess this is more an operating system question that a libc one.
Since you are talking about the OOM killer, I further guess that
your context is Linux. In this case, your magic keyword is
"memory overcommitment". There is a setting for that, see for
example here:
https://www.kernel.org/doc/html/v5.1/vm/overcommit-accounting.html
Cheers
--
t
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
next prev parent reply other threads:[~2023-06-05 4:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-05 0:28 Konstantin Kharlamov
2023-06-05 4:41 ` tomas [this message]
2023-06-05 6:39 ` Florian Weimer
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=ZH1nk2JiiOGA9isg@tuxteam.de \
--to=tomas@tuxteam.de \
--cc=hi-angel@yandex.ru \
--cc=libc-help@sourceware.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.
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 read-only IMAP folder(s) and NNTP newsgroup(s).