Applescript show free memory
Hey,
I need an applescript that display the free memory in a textfield or a lable.
Any ideas?
thanks
You can make a difference in the Apple Support Community!
When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.
When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.
Hey,
I need an applescript that display the free memory in a textfield or a lable.
Any ideas?
thanks
It is mostly meaningless since the value is constantly changing, but you can use vm_stat, for example
# get the number of free pages using 'vm_stat' and multiply by the page size
setvmStatsto (text12thru-2of (do shell script"vm_stat | grep 'Pages free'")) * 4096
display dialogvmStatswith title"Memory usage"buttons {"OK"} default button1
Nice idea, but it doesn't work. In the applescript editor it worked but the number of the memory usage is a big fail 😀 and in xcode in the textfield it displays nothing.
Works for me - what kind of error are you getting and what code are you using?.
there is no error, but it it's like display dialog with a big number (3743839282737). For me its better if there is the correct free memory 😀 and its in a text field
I can't guess what your particular program statements are since you didn't provide any, so I just posted an example. The big number is the free memory, although I suppose it depends on what you are calling free (and it does change a lot). Just use your text field's setStringValue_ method to put the number in it.
Why on Earth are you worried about free memory?
The OS takes care of that and nothing you do in your program can 'Clean Memory'.
Sie vergeuden Ihre Zeit.
Well do you hear anything about the terminal command "purge"? It's a very effactive command that help ME a lot. and google says that it helps other people as well.
If that does in fact free up memory, something is wrong in OS X.
The user should NEVER have to fiddle with memory to make the system run better.
Every thing is running good in my os. its just a addition or do you leave any data you dont need at all on your hard drive?
Data on the hard drive has absolutely nothing to do with the amount of available random access memory (RAM) which is what your trying to display.
its the same princip. i dont leave data on my hard drive if its not need. the same with ram. if there are processes they need to much or they run but i dont need it, i clean the ram, so other programms can use the ram. lets doesnt talk about the functionality, lets talk about the script.
ahh, and they are so many programms in the mac app store and they do the same. look on the ratings. they often got good ratings.
Last time: Memory management is handled by OS X. Application programs cannot 'free memory'.
in applescript application
code:
on ram_(sender)
do shell script "purge"
end ram_
The purge utility is mainly used when doing a performance analysis. As has been beaten to death in your other topics, the OS keeps track of RAM that is not being used so that it can be used by other processes as needed. Anything you do to "free" memory is going to negatively affect the system performance, since things in memory that might be used again have been removed.
All you need to do is put the results(s) from the vm_stat shell script (take a look at the manual page I have linked) into your text field. A momentary snapshot of the free memory isn't really going to do much good though (since it constantly changes), so your program should really be constantly updating the text field, which is going to involve things such as NSTask and NSPipe. A screenshot of your UI isn't going to help nearly as much as some code.
Applescript show free memory