On Thu, Jun 20, 2019 at 10:22:35AM +0300, megane wrote:
> Hi,
> 
> I think the docs are saying the returned values should be
> semi-space-size, used-semi-space and nursery size. The patch makes it so.

Attached is a signed-off copy.  I fixed the version number in the NEWS
file, because the next snapshot will be 5.1.1, not 5.2.0.

I also didn't just push it, even though the patch itself is trivial; I
don't know if this is a documentation bug or a code bug.

Cheers,
Peter
From 9b87881affde6c89ab5f0003fee4a7f27ae056ca Mon Sep 17 00:00:00 2001
From: megane <megan...@gmail.com>
Date: Thu, 20 Jun 2019 10:14:50 +0300
Subject: [PATCH] Fix memory-statistics

Fixes #1540

Signed-off-by: Peter Bex <pe...@more-magic.net>
---
 NEWS        | 7 +++++++
 library.scm | 4 ++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index aa5f1d14..6819856a 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +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).
+
 5.1.0
 
 - Core libraries
diff --git a/library.scm b/library.scm
index b7d0c10e..80d76579 100644
--- a/library.scm
+++ b/library.scm
@@ -6020,8 +6020,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:
 
-- 
2.11.0

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-hackers

Reply via email to