Does The Big Box object work properly for 64-bit?
Hey, folks! Another question...
I'm using The Big Box object to determine how much total RAM is available on the computer in which the MMF2 application is running. I have a condition in an event which states that if the Total RAM (not Available RAM) is less than 4, then perform an action. A test computer I'm using has 4 GB of RAM, but it is still triggering the action. To test, I set the condition for "less than or equal to 3," and it still triggers.
So, I began to wonder whether The Big Box object doesn't quite function properly on 64-bit operating systems? Or, which is more probable, I'm doing something wrong.
Any ideas?
Thanks!
RGBreality
Re: Does The Big Box object work properly for 64-bit?
Well, The Big Box appears to return the amount of RAM in megabytes, not gigabytes. So you are using it incorrectly in that respect. This is strange, however, because if you're using the "less than or equal to" comparison, the condition should never be true, instead of always being true.
If you think it isn't working for 64-bit, just set a counter to the total RAM at the start of the frame. If the number you get is incorrect, you know it isn't working. :)
Re: Does The Big Box object work properly for 64-bit?
I can't see it work for more than 2GB ram because that's the maximum that a signed integer can take (which is what MMF parameters use). FYI, numbers greater than 2 GB will be negative in MMF. So comparisons totally fail.
Re: Does The Big Box object work properly for 64-bit?
Although according to the post above it's returned in megabytes, so MMF limits wouldn't be an issue.
Re: Does The Big Box object work properly for 64-bit?
Sorry, brain leakage, I did read that, but I was thinking "not GB? must be bytes" for some reason :blush:
Re: Does The Big Box object work properly for 64-bit?
I wonder... Is there a way to read the total amount of RAM through the registry (much as one can determine the processor and its clock speed)? I suspect that its value in the registry would be a binary number, which would mean one would need to convert it to decimal before making any condition checks.
Would that be possible?
RGBreality
Re: Does The Big Box object work properly for 64-bit?
What do you mean, a binary number? In a computer numbers are all stored the same way (Either as integer or float) - There is no "decimal" or "binary". Those are just representations of the same value. There should be no conversion necessary whatsoever. :)
It's actually possible without the registry:
http://msdn.microsoft.com/en-us/library/aa366586(v=VS.85).aspx
You could basically do this with the DLL object. If there is no better solution, I'll make you an example when I get home tomorrow.
Re: Does The Big Box object work properly for 64-bit?
I used the Ex version instead because it supports 64-bit for you, RGBreality. (and coincidentally it unintentionally has a size of 64 bytes XD ).
Here is the example MFA:
http://mfa.aquadasoft.com/view/1316654752-GlobalMemoryStatusEx
Note: the Advanced Int64 Object, as the name suggestes, deals with integers. The gigabyte values are rounded down - if you want a more accurate measurement, convert it to megabytes or kilobytes first and then use MMF2's floating point division instead ;)
EDIT: So sorry, I had accidentally used a newer version of my Advanced Int64 object that I had forgotten to release. I have released it now so please download before opening the example:
http://www.clickteam.com/epicenter/ubbthreads.php?ubb=showflat&Number=249164#Post2491 64
Re: Does The Big Box object work properly for 64-bit?
Thanks LB :) The GB calculation is wrong, though. It says 4285652992 bytes total, but only 3 GB.
Would be nice if the Advanced Int64 Object could read from the memory, btw.
Re: Does The Big Box object work properly for 64-bit?
Hey, LB! Thank you for your help (yet again!).
I incorporated your code into my application, and it seems to run well. The only thing that might be amiss is when I perform a check for the amount of total physical memory in the computer against a prerequisite amount, the check fails when it should not.
Specifically, the computer has 4 GB of physical memory, which is the exact prerequisite required. My event looks like this:
Condition: UDiv$( "Advanced Int64 Object", GetUnsignedVar$( "Advanced Int64 Object", "TotalPhys"), "1073741824") < 4
Action: String: "This computer has "+UDiv$( "Advanced Int64 Object", GetUnsignedVar$( "Advanced Int64 Object", "TotalPhys"), "1073741824")+" GB of physical memory. Please install more physical memory."
At run-time, the action message displays that there are 3 GB of physical memory instead of 4. So, the condition is met appropriately, though it shouldn't occur.
Thoughts?
Most appreciatively...
RGBreality
Re: Does The Big Box object work properly for 64-bit?
That's pretty much the same problem I had ;) I just realized that it's not actually his fault, though. I asked Google:
((4 285 652 992 / 1024) / 1024) / 1024 = 3.99132538
Task Manager confirms this: It says I have 4087 MB RAM. I guess the problem is that we don't have exactly 4 GB or some are hidden or so. I don't know. What you could do, as a kind of hack, is to add a certain number to the available bytes. I guess 100 MB (= 100*1024*1024) should work - 4087+100 is 4187 which is above 4096 (4 GB). I hope somebody has a better solution though.