The sysutils/htop port reads /compat/linux/proc/meminfo to calculate the amount of memory used.
The code that generates this file resides in sys/compat/linprocfs/linprocfs.c. Here, the amount of available memory is intentionally misreported:
* The correct thing here would be:
memfree = cnt.v_free_count * PAGE_SIZE;
memused = memtotal - memfree;
* but it might mislead linux binaries into thinking there
* is very little memory left, so we cheat and tell them that
* all memory that isn't wired down is free.
memused = cnt.v_wire_count * PAGE_SIZE;
memfree = memtotal - memused;
Fix: The attached patch uses sysctl to read the actual amount of available memory, just as top does.
Patch attached with submission follows:
How-To-Repeat: Run top and htop simultaneously. Notice that htop reports very low memory usage while top reports the correct value.
Over to maintainer (via the GNATS Auto Assign Tool)
Here is my rewritten patch. It uses sysctl and llibkvm for memory
info, without linux proc.
I think that there is a need to include it to sysutils/htop and bump
2011/7/24 Sayetsky Anton <firstname.lastname@example.org>:
> Here is my rewritten patch. It uses sysctl and llibkvm for memory
> info, without linux proc.
> I think that there is a need to include it to sysutils/htop and bump
Sorry, there is a small difference (about 40 mbytes) between used mem
that reports top and htop with previous patch. I've attached a new
version of ProcessList.c patch.
Also, may we need to add special counter for inactive memory?
Maintainer was changed
Is this still valid for 0.9? If yes, can you contact the new maintainer about it?
Yes, htop-0.9 still has bug with memory calculation. I will write a
patch for new version as soon as possible.
Here is a patch for htop-0.9, with it htop calculates all memory usage
correctly ("used mem" in htop means freebsd's active memory).
Please, bump portrevision and commit.
pav 2011-08-12 08:30:34 UTC
FreeBSD ports repository
- Fix calculation of available memory
Submitted by: Sayetsky Anton <email@example.com>
Approved by: Hung-Yi Chen <firstname.lastname@example.org> (maintainer)
Revision Changes Path
1.21 +1 -0 ports/sysutils/htop/Makefile
1.5 +87 -0 ports/sysutils/htop/files/patch-ProcessList.c (new)
1.4 +11 -3 ports/sysutils/htop/files/patch-configure.ac
email@example.com mailing list
To unsubscribe, send any mail to "firstname.lastname@example.org"