[SOLVED] Insane ram usage.

I am using slstatus to display ram usage in percent, and it shows "-830053581%". How is this possible?
And I would also like to control volume from slstatus, and instructions are "vol_perc OSS/ALSA volume in percent mixer file (/dev/mixer)" but there is nothing like /dev/mixer. I did whereis mixer and then tried /usr/sbin/mixer but didn't work.
Thank you.
 
Is that "s-lowercase L-status"? I'm not seeing that in either pkg search or grepping INDEX-13 from a ports tree. I agree with SirDice but without being able to see source code it's hard to give definite answers.
 
I'm not seeing that in either pkg search or grepping INDEX-13 from a ports tree.
I believe it's this one: https://github.com/drkhsh/slstatus

how are you doing the calculation?
The code to compute RAM usage in percent would be this: https://github.com/drkhsh/slstatus/blob/master/components/ram.c
Code:
#elif defined(__FreeBSD__)
    #include <sys/sysctl.h>
    #include <sys/vmmeter.h>
    #include <unistd.h>
    #include <vm/vm_param.h>

   /* --- SNIP --- */

    const char *
    ram_perc(void) {
        long npages;
        long active;
        size_t len;

        len = sizeof(npages);
        if (sysctlbyname("vm.stats.vm.v_page_count", &npages, &len, NULL, 0) == -1
                || !len)
            return NULL;

        if (sysctlbyname("vm.stats.vm.v_active_count", &active, &len, NULL, 0) == -1
                || !len)
            return NULL;

        return bprintf("%d", active * 100 / npages);
    }

   /* --- SNIP --- */

#endif
 
active appears to be a correct value but where is it getting npages from?
 
Oh, right, missed that one. So on my system that would be get these values:
Code:
root@molly:~ # sysctl vm.stats.vm.v_page_count
vm.stats.vm.v_page_count: 4028834
root@molly:~ # sysctl vm.stats.vm.v_active_count
vm.stats.vm.v_active_count: 5578

And the calculation would produce:
Code:
root@molly:~ # dc
>>> 2k
>>> 5578
>>> 100 *
>>> 4028834 /
>>> p
.13
Something looks off here.
 
So what should I do?
You could figure out how to properly compute the RAM usage in percent, check out the source, add your changes, compile and be happy.
If you want to be a hero you could then open a pull request and make your changes public. But unfortunately, the project seems inactive so i guess no luck with the pull request.

Don't know about the volume control
 
You could figure out how to properly compute the RAM usage in percent, check out the source, add your changes, compile and be happy.
If you want to be a hero you could then open a pull request and make your changes public. But unfortunately, the project seems inactive so i guess no luck with the pull request.

Don't know about the volume control
Instead of using ram percentage, i tried ram used / ram total.
In both used and total, it says "512.0 Pi".
Doen't matter if i close terminal and open new browser instance and tabs, it stays the same.
 
The problem is 'long' is size 8, or 64-bit, on 64-bit platforms, but the length of the data stored in 'len' by each call is 4, or 32-bit. Printing 'len' after each call is what reveals that. Initialize the 'active' and 'npages' variables to 0 and the problem disappears because the 32-bit values are written to the lower 32-bit half of those variables.
 
The problem is 'long' is size 8, or 64-bit, on 64-bit platforms, but the length of the data stored in 'len' by each call is 4, or 32-bit. Printing 'len' after each call is what reveals that. Initialize the 'active' and 'npages' variables to 0 and the problem disappears because the 32-bit values are written to the lower 32-bit half of those variables.
I am sorry I don't know how to do that. Do I have to edit the ram.c file? I am guessing I have to do something like npages=0 and active=0. Can you please tell me what and where should I do this?
 
Back
Top