~ chicken-core (chicken-5) 126a315f1ffba0bd33709c05132063affddee266


commit 126a315f1ffba0bd33709c05132063affddee266
Author:     megane <meganeka@gmail.com>
AuthorDate: Thu Jun 20 10:14:50 2019 +0300
Commit:     Evan Hanson <evhan@foldling.org>
CommitDate: Wed Jul 3 20:44:41 2019 +1200

    Fix memory-statistics
    
    Fixes #1540
    
    Signed-off-by: Peter Bex <peter@more-magic.net>
    Signed-off-by: Evan Hanson <evhan@foldling.org>

diff --git a/NEWS b/NEWS
index e15ec4e3..f7c5413c 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,10 @@
 5.1.1
 
+- Core libraries
+  - Fix `memory-statistics` by returning semi-space bytes and used
+    semi-space bytes like the documentation says. Old implementation
+    returned full-heap size and (full-heap - used-semi-space).
+
 - Compiler
   - Fixed a bug in lfa2 pass which caused "if" or "cond" nodes to be
     incorrectly unboxed if the "else" branch had a flonum result type
@@ -7,6 +12,7 @@
   - Inline files no longer refer to unexported foreign stub functions
     (fixes #1440, thanks to "megane").
 
+
 5.1.0
 
 - Core libraries
diff --git a/library.scm b/library.scm
index 994efc4d..998b438c 100644
--- a/library.scm
+++ b/library.scm
@@ -6022,8 +6022,8 @@ static C_word C_fcall C_setenv(C_word x, C_word y) {
 (define (memory-statistics)
   (let* ((free (##sys#gc #t))
 	 (info (##sys#memory-info))
-	 (hsize (##sys#slot info 0)))
-    (vector hsize (fx- hsize free) (##sys#slot info 1))))
+	 (half-size (fx/ (##sys#slot info 0) 2)))
+    (vector half-size (fx- half-size free) (##sys#slot info 1))))
 
 ;;; Finalization:
 
Trap