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

JavaSysMon returns wrong result for free swap on Windows #2

Open
jezhumble opened this issue Aug 30, 2010 · 0 comments
Open

JavaSysMon returns wrong result for free swap on Windows #2

jezhumble opened this issue Aug 30, 2010 · 0 comments

Comments

@jezhumble
Copy link
Owner

new JavaSysMon.swap().getFreeBytes()

works incorrectly under Windows, it returns the amount of used virtual memory, not free. It's very easy to test - just load or unload some applications and check the result.

http://github.com/jezhumble/javasysmon/blob/master/src/main/c/windows/javasysmon.c

JNIEXPORT jobject JNICALL Java_com_jezhumble_javasysmon_WindowsMonitor_swap (JNIEnv *env, jobject obj)
{...
(jlong) (pagesize * perfinfo.CommitTotal), // should be (perfinfo.CommitLimit - perfinfo.CommitTotal)
(jlong) (pagesize * perfinfo.CommitLimit));...
}
CommitTotal
The number of pages currently committed by the system. Note that committing pages (using VirtualAlloc with MEM_COMMIT) changes this value immediately; however, the physical memory is not charged until the pages are accessed.
CommitLimit
The current maximum number of pages that can be committed by the system without extending the paging file(s). This number can change if memory is added or deleted, or if pagefiles have grown, shrunk, or been added. If the paging file can be extended, this is a soft limit.

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

1 participant