On 20/02/14 21:07, Gabriel Johnson wrote:
Hey All,
I am working on a program where I need to know the amount of available
memory.
I'm running on OS X and hasMemory() appears to return true/false for the
same values regardless changes to free/available memory. Is there some
trick to getting hasMemory() to correspond with the actual available
memory? Is this possibly something that is being addressed in newer
versions of LiveCode?
As a side note, we would prefer to only use external programs/the shell
sparingly. I've used both top and vm_stat and each appeared to have
presented problems (top seemed to have changed in Mountain Lion and vm_stat
seems to occasionally fail for a reason I haven't yet figured out). If the
shell / external process is the only way then I guess we'll work through it.
Gabe
_______________________________________________
I would suggest that you read the documentation which states this (LC 6.6):
"This function is only partially implemented, and may not return useful
values on some platforms. It is included in LiveCode for compatibility
with imported SuperCard projects.
Cross-platform note: On Mac OS systems, the value returned depends on
the amount of free memory in the application heap and does not take
available temporary memory into account. This means that even if the
hasMemory function returns false, there may be enough system memory
available for the task, since LiveCode uses temporary memory when
necessary."
So, probably, rather a waste of time.
Exploring hasMemory() further I realise it will NOT tell you how much
free memory you have as you have to provide parameters inside those
brackets. What is (might) do is tell you whether the amount of free
memory exceeds the amount you specify within those brackets.
-----------------------------------------------
Over her on Linux you can do this in a terminal:
cat /proc/meminfo
which gives you loads of funny numbers: the second of which is 'MemFree'
I don't know whether that works on Mac OS X, but as they share a common
ancestry (they do, ye know), it might.
------------------------------------------------
What might be useful in LC is something that yields the equivalent of
MemFree (or its equivalent on Mac and Windows).
Mind you if you are worrying about how much free memory the host
computer has you must be running some sort of monster thing.
------------------------------------------------
You can also just type 'free' into a Terminal, at which point the
numbers are a lot less funny insofar as they are better labelled
and easier to understand.
------------------------------------------------
On a marginally tangential note . . .
In another universe where everything is marvellous we might have a
Livecode which would do all and everything for us
without having to rely on anything external at all (perhaps even bring
us coffee in bed on Sunday mornings).
But that other universe would feature one type of computer, running one
operating system; neither of which changed,
and be incredibly, unutterably boring.
We all, on this Use-list and beyond, would like a programming
environment that "did it all" but that is not possible.
What never ceases to amaze me is just how much Livecode can do; and what
never ceases to amaze me is how little I know
about Livecode's capabilities after about 13 years with it, and how much
I learn everytime I try to do something new (however
trivial) with it. [OK, OK, RunRev; contact me off-list for my bank acc.
number for the fees for that one . . . . . LOL].
Richmond.
_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode