Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RAM usage is incorrect #58

Closed
olidem00 opened this issue Nov 28, 2020 · 1 comment
Closed

RAM usage is incorrect #58

olidem00 opened this issue Nov 28, 2020 · 1 comment

Comments

@olidem00
Copy link

I have been experimenting with your API to include my server stats on a web app. I did notice that the memory reading was incorrect:
Actual value:
image
Value displayed:
displayed

I know someone already pointed this out in issue #19, and you explained that it was caused by the heap size being different than the actual memory size.

I have reviewed your source code, and it appears the issue comes from lines 15 to 17 in WebConsole-2.0-rev2\src\es\mesacarlos\webconsole\websocket\command\RamUsageCommand.java:

image

You see, maxMemory() is the maximum heap size, whereas freeMemory() is the free heap size memory. Therefore, in order to get usage, you need to modify the code to this:
image

This resolved my issue, as totalMemory() is the current heapsize, which is more often than not way lower than the actual heap limit:
image

Other than that, I love your plugin, and it has been exactly what I was looking for, so many thanks for making it 👍

Hope this could help !

@mesacarlos
Copy link
Owner

mesacarlos commented Nov 28, 2020

Hello,

Thank you for your research and posting this issue!
I didn't notice the problem because I was running my server with -Xmx1G -Xms1G params, so every time I tested it it was OK because maxMemory() and totalMemory() were basically the same...

I'm releasing a new version now with this issue solved.
Thank you again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants