File 0855-stdlib-garbage-collect-when-saved-shell-history-resu.patch of Package erlang

From b1f4ae8db69a7bf77c340c1bdcd8cdb4a4c68bb2 Mon Sep 17 00:00:00 2001
From: frazze-jobb <frazze@erlang.org>
Date: Tue, 12 Sep 2023 14:09:45 +0200
Subject: [PATCH] stdlib: garbage collect when saved shell history results are
 reduced.

OTP-18773
---
 lib/stdlib/doc/src/shell.xml | 2 ++
 lib/stdlib/src/shell.erl     | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/lib/stdlib/doc/src/shell.xml b/lib/stdlib/doc/src/shell.xml
index 3ce6ef9298..9f3849b0c3 100644
--- a/lib/stdlib/doc/src/shell.xml
+++ b/lib/stdlib/doc/src/shell.xml
@@ -146,6 +146,8 @@
       <tag><c>f(X)</c></tag>
       <item>
         <p>Removes the binding of variable <c>X</c>.</p>
+        <note><p>If a huge value is stored in a variable binding, you have to both call <c>f(X)</c> and
+    call <c>history(0)</c> or <c>results(0)</c> to free up that memory.</p></note>
       </item>
       <tag><c>h()</c></tag>
       <item>
diff --git a/lib/stdlib/src/shell.erl b/lib/stdlib/src/shell.erl
index 834a570c7f..af9aea26d6 100644
--- a/lib/stdlib/src/shell.erl
+++ b/lib/stdlib/src/shell.erl
@@ -237,6 +237,8 @@ server_loop(N0, Eval_0, Bs00, RT, FT, Ds00, History0, Results0) ->
                     if
                         HB ->
                             garb(self());
+                        Results < Results0 ->
+                            garb(self());
                         true ->
                             ok
                     end,
-- 
2.35.3

openSUSE Build Service is sponsored by