* bug#43395: memory leaks
[not found] <m3y2ja9f6f.fsf@leonis4.robolove.meer.net>
@ 2020-11-10 14:22 ` Jean Louis
2020-11-10 15:28 ` Eli Zaretskii
0 siblings, 1 reply; 4+ messages in thread
From: Jean Louis @ 2020-11-10 14:22 UTC (permalink / raw)
To: Madhu; +Cc: 43395
* Madhu <enometh@meer.net> [2020-11-10 04:27]:
> [Test case follows. Sorry Drew for trying to post to help-gnu and
> debbugs simultaneously, but this is my third attempt at sending this
> test case - I've tried sending it to debbugs.gnu.org and to
> gmane.emacs.help newsgroup - and my messages have been dropped]
>
>
> * Madhu <m35z8gise6.fsf@leonis4.robolove.meer.net> :
> Wrote on Mon, 14 Sep 2020 15:36:57 +0530:
> > The numbers I reported by garbage-collect do not account for the memory
> > usage. FWIW I've posted that info again at
> > https://debbugs.gnu.org/cgi/bugreport.cgi?bug=43395
>
> I found test case for this bug and I sent mail to 43395@debbugs.gnu.org,
> and qmail told me that the mail was accepted:
> delivery 1: success:
> 209.51.188.43_accepted_message./Remote_host_said:_250_OK_id=1kc8Bf-00061T-3u/
> But the bugreport didn't show up on gnu.emacs.bug.
>
> Here is the test case:
>
> #+BEGIN_SRC
> $ cat > f.c
> #include <stdio.h>
> int
> main()
> {
> char c = ' ';
> while (c != 'q' && c != 'Q')
> {
> fprintf(stdout, "Press q then enter to quit: ");
> c = fgetc(stdin);
> }
> return 0;
> }
> ^D
>
> $ gcc f.c
> $ emacs -Q
> #+END_SRC
>
> M-x shell-command ./a.out
>
> Then the process hangs. But Emacs' memory grows unbounded.
>
> WARNING. Be careful to interrupt it with ^G before the OOM killer
> kicks in. If you have swap you may lose control of your machine
> indefinitely.
>
> After you interrupt the sub process, Emacs is left with unreclaimed
> gigabytes of RSS
>
> Please let me know if you can reproduce this
Me I have been testing now. It all blocks. Then I had to switch to
console from X to kill process.
I can see memory is not reclaimed graphically. Not practically. I have
graphical indicator.
This same things happens from time to time in Emacs. Exactly like you
say when I have swap I may lose control of machine. Then I had to
power off with the hard key. Bad.
I hope this can be resolved.
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#43395: memory leaks
2020-11-10 14:22 ` bug#43395: memory leaks Jean Louis
@ 2020-11-10 15:28 ` Eli Zaretskii
2020-11-10 19:40 ` Jean Louis
2020-11-10 20:29 ` Madhu
0 siblings, 2 replies; 4+ messages in thread
From: Eli Zaretskii @ 2020-11-10 15:28 UTC (permalink / raw)
To: Jean Louis; +Cc: enometh, 43395
> Date: Tue, 10 Nov 2020 17:22:46 +0300
> From: Jean Louis <bugs@gnu.support>
> Cc: 43395@debbugs.gnu.org
>
> > #+BEGIN_SRC
> > $ cat > f.c
> > #include <stdio.h>
> > int
> > main()
> > {
> > char c = ' ';
> > while (c != 'q' && c != 'Q')
> > {
> > fprintf(stdout, "Press q then enter to quit: ");
> > c = fgetc(stdin);
> > }
> > return 0;
> > }
> > ^D
> >
> > $ gcc f.c
> > $ emacs -Q
> > #+END_SRC
> >
> > M-x shell-command ./a.out
> >
> > Then the process hangs. But Emacs' memory grows unbounded.
This is expected, and is not a bug.
'shell-command' is intended for running non-interactive programs,
those which produce output, but don't expect any input. So it runs
the sub-process with its standard input connected to the null device.
Your program has a bug in that case: it doesn't detect the EOF
condition on its standard input (to see that, invoke it as
"./a.out < /dev/null"). So it loops indefinitely, with each iteration
pumping the prompts into Emacs, which obediently collects that in a
buffer, that grows and grows and grows, until it eats up all the
available memory. And evidently, you didn't configure your system to
have resident size limitation on user processes, so instead of
reporting "memory full", Emacs is allowed to eat up all your memory
and swap.
In short: don't do that.
I see no bug here: Emacs cannot know in advance how much stuff will be
emitted by the sub-process, and it cannot know how much memory it cqan
swallow before OOMK will sporing into action.
And, of course, this is unrelated to the problems being discussed in
this bug report.
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#43395: memory leaks
2020-11-10 15:28 ` Eli Zaretskii
@ 2020-11-10 19:40 ` Jean Louis
2020-11-10 20:29 ` Madhu
1 sibling, 0 replies; 4+ messages in thread
From: Jean Louis @ 2020-11-10 19:40 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: enometh, 43395
* Eli Zaretskii <eliz@gnu.org> [2020-11-10 18:28]:
> > > M-x shell-command ./a.out
> > >
> > > Then the process hangs. But Emacs' memory grows unbounded.
>
> This is expected, and is not a bug.
>
> 'shell-command' is intended for running non-interactive programs,
> those which produce output, but don't expect any input. So it runs
> the sub-process with its standard input connected to the null device.
> Your program has a bug in that case: it doesn't detect the EOF
> condition on its standard input (to see that, invoke it as
> "./a.out < /dev/null"). So it loops indefinitely, with each iteration
> pumping the prompts into Emacs, which obediently collects that in a
> buffer, that grows and grows and grows, until it eats up all the
> available memory. And evidently, you didn't configure your system to
> have resident size limitation on user processes, so instead of
> reporting "memory full", Emacs is allowed to eat up all your memory
> and swap.
Thank you, it helps!
Do I need to use `ulimit -m'?
I guess following should be for 1 GiB:
ulimit -m 1048576
and this for 2 GiB:
ulimit -m 2097152
Now I can execute ./a.out without getting blocked in Emacs. I will see
how to tweak that more.
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#43395: memory leaks
2020-11-10 15:28 ` Eli Zaretskii
2020-11-10 19:40 ` Jean Louis
@ 2020-11-10 20:29 ` Madhu
1 sibling, 0 replies; 4+ messages in thread
From: Madhu @ 2020-11-10 20:29 UTC (permalink / raw)
To: eliz; +Cc: 43395, bugs
* Eli Zaretskii <eliz@gnu.org> <83k0ut2pv6.fsf@gnu.org>
Wrote on Tue, 10 Nov 2020 17:28:13 +0200
> This is expected, and is not a bug.
>
> 'shell-command' is intended for running non-interactive programs,
> those which produce output, but don't expect any input. So it runs
> the sub-process with its standard input connected to the null device.
> Your program has a bug in that case: it doesn't detect the EOF
> condition on its standard input (to see that, invoke it as
> "./a.out < /dev/null"). So it loops indefinitely, with each iteration
> pumping the prompts into Emacs, which obediently collects that in a
> buffer, that grows and grows and grows, until it eats up all the
> available memory. And evidently, you didn't configure your system to
> have resident size limitation on user processes, so instead of
> reporting "memory full", Emacs is allowed to eat up all your memory
> and swap.
>
> In short: don't do that.
>
> I see no bug here: Emacs cannot know in advance how much stuff will be
> emitted by the sub-process, and it cannot know how much memory it cqan
> swallow before OOMK will sporing into action.
>
> And, of course, this is unrelated to the problems being discussed in
> this bug report.
Sorry, yes - the memory is indeed freed up when *Shell Command Output*
is killed. I was mistaken in thinking that the memory was not freed
up when all the buffers had been deleted.
Apologies.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-11-10 20:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <m3y2ja9f6f.fsf@leonis4.robolove.meer.net>
2020-11-10 14:22 ` bug#43395: memory leaks Jean Louis
2020-11-10 15:28 ` Eli Zaretskii
2020-11-10 19:40 ` Jean Louis
2020-11-10 20:29 ` Madhu
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).