What's new

Solved Displayed memory usage error in WebUI

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

It's not that simple, as I don't store it anywhere, it's directly manipulated as a float, and sent as text to the web page:

Code:
                        sprintf(result,"%.2f",(sys.totalswap * sys.mem_unit / (float)MBYTES));

The original bug was that the value wasn't multiplied by the unit size value (in your test, multiplying both values would give you 5 GB). If it still has issues reporting large values, then it's something else causing the whole calculation to fail (and it would be specific to ARM, as I couldn't reproduce the issue on a test case compiled for x86).
its just cosmetic anyways right?
 
It's not that simple, as I don't store it anywhere, it's directly manipulated as a float, and sent as text to the web page:

Code:
                        sprintf(result,"%.2f",(sys.totalswap * sys.mem_unit / (float)MBYTES));

The original bug was that the value wasn't multiplied by the unit size value (in your test, multiplying both values would give you 5 GB). If it still has issues reporting large values, then it's something else causing the whole calculation to fail (and it would be specific to ARM, as I couldn't reproduce the issue on a test case compiled for x86).
I don't think the calculation is failing as such. I don't know how that code works internally but there's obviously some sort of unsigned 32-bit precision in play. I don't think it's the sprintf statement so I'm assuming that sys.totalswap * sys.mem_unit is a 32-bit integer calculation.

I created a swap file that was exactly 7GB (#1C0000000 bytes) in size, so the 31st, 32nd and 33rd bits are set.
Code:
# free
             total       used       free     shared    buffers     cached
Mem:        934032     906284      27748       2396        464     557856
-/+ buffers/cache:     347964     586068
Swap:      7340032          0    7340032

# ./test-swap
unit_size: 4096 - total swap: 1835008

When viewed in the GUI it shows as 3072.00MB, or #C0000000 bytes. So something is truncating the value to an unsigned 32-bit number.
Untitled.png
 
Last edited:

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top