Dear sir,
I have some remarks about JavaSysMon. I dont know the best place to send them, so i decided to put it in an email. First i like to compliment you on the nice library. Its simple, easy to understand and the license makes it usable for general use. I was always disappointed why something as big as java doesn't have some basic functionality to get the pid or cpu usage. Therefore i *really* hope your lib is here to stay and gets the popularity it deserves.
I also got a small remark about some small issue on win32. I think you already know it and decided to ignore it for backwards compatibility, but on my win32 system (3GB ram) the ammount of memory is reported incorrectly (2GB). I looked into the source and it showed the use of GlobalMemoryStatus while msdn recommends GlobalMemoryStatusEx. I dont know the ins and outs about c++ anymore but would it be possible to see if the GlobalMemoryStatusEx is available (which probably is not on i.e. win95) and use that instead of GlobalMemoryStatus.
I'm not sure if what i am saying is making complete sense since it has been 10 years i did anything in c/c++, but i think you'll understand what i mean :).
Regards,
J de Vries
PS although i'm sure you don't need it, but this is what i changed to get it working on my system. I think it doesn't work on older windows (win95) but i'm not sure how to check this since msdn only seems to support win2k since i haven't seen any function on msdn which is guaranteed to be in win95. I was thinking about using GetProcAddress but i don't know if i can use it if i want to preserve backwards compatibility either.
JNIEXPORT jobject JNICALL Java_com_jezhumble_javasysmon_WindowsMonitor_physical (JNIEnv *env, jobject obj)
{
MEMORYSTATUSEX statex;
jclass memory_stats_class;
jmethodID memory_stats_constructor;
jobject memory_stats;
statex.dwLength = sizeof(statex);
GlobalMemoryStatusEx (&statex);
memory_stats_class = (*env)->FindClass(env, "com/jezhumble/javasysmon/MemoryStats");
memory_stats_constructor = (*env)->GetMethodID(env, memory_stats_class, "<init>", "(JJ)V");
memory_stats = (*env)->NewObject(env, memory_stats_class, memory_stats_constructor, (jlong) statex.ullAvailPhys, (jlong) statex.ullTotalPhys);
(*env)->DeleteLocalRef(env, memory_stats_class);
return memory_stats;
}
Dear mister Humble,
It seems my previous assumption that you were using an old function
was wrong. Still i don't think it would be bad to use the if the
alternative wasn't available (GlobalMemoryStatusEx). Although i did
program a complete program in win32 once, i forgot all but the very
basics about win programming and c++. I would be delighted to help you
develop the library (although i already think its pretty solid) im not
sure where i could be of assistance.
I also thought about posting in the google groups, but i wasn't really
sure if that was the best place to do it.It might be a good idea to
post a link to it somehwere on your site maybe ?
My best advise i can give now is to use the MSDN site from microsoft
very carefully for any function you use. That can prevent unwanted
behavior since the documentation is pretty solid. Unfortunately i've
never found a reasonable counterpart for MSDN on linux. That reminds
me, you support windows, but what versions exactly? If i i might give
a suggestion i would support from win2k up since
- msdn is only usefull for win2k+ since older information seems to be
deleted from msdn
- you have no backwards to compatibility worry about since your lib
is pretty new.
- i would guess you need to do a lot more coding to find alternative
solutions for functions win2k has, while this would only be usable for
a very few people.
- its hard to really support old windows, i dont know about you but i
don't have any hardware that runs win98 and installation on my virtual
machine was a bit iffy.
Regards,
jdv