[TOOL/SCRIPT/RC2]FreeXplain-r / freex-BETTER than free & Why "free" RAM ISN'T WASTED!

Is this better than free?

  • Yes

    Votes: 52 96.3%
  • No

    Votes: 2 3.7%

  • Total voters
    54
Search This thread

zeppelinrox

Senior Member
Dec 21, 2010
9,374
21,590
IN THE FREAKIN' OP
[TOOL/SCRIPT/RC2]FreeXplain-r / freex-BETTER than free & Why "free" RAM ISN'T WASTED!

See Post #2 for Installation/Requirements/Download.

Now before getting into my new tool, I'd like to explain why I felt the need to even bother making it.

First of all, if you've ever typed "free" in terminal, you'd see that it shows almost no free ram while any app you check with would show lots of free ram.

This what it looks like.

p2pzzt3rkti5xms6g.jpg


Now if you're like me, you'd probably do a google search to figure out what the hell it means lol
Because I had over 200 mb "free" when I took that screen shot but that shows only 40mb free and it would be nice if it actually made some sense ;)

Some of you familiar with my V6 SuperCharger may have read this post of mine before: "Why 'Free RAM' Is NOT Wasted RAM!"
In there, I post some findings from my first hand experience and how it correlates with this article Linux Memory Consumption (which I had found afterwards)
Unfortunately, that page is now down but I had a saved copy in PDF format which I've attached.

In that pdf, it reads "The absolute free memory number is not only the value of MemFree, but the sum of the MemFree, Buffers and Cached fields."

There are many pages that can help you figure it out.
Here is a good one Check Linux Memory Usage Using Free Command

If you need to know exactly what buffers and cache actually are, click the button
Info taken from http://nilesh-joshi.blogspot.ca/2010/04/interpreting-output-of-free-command.html


  • The "buffers" column shows the amount of memory being used by the kernel buffer cache. The buffer cache is used to speed up disk operations, by allowing disk reads and writes to be serviced directly from memory. The buffer cache size will increase or decrease as memory usage on the system changes; this memory is reclaimed if it is needed by applications.
  • The "cache" column indicates how many memory pages the kernel has cached for faster access later. Since the memory used for buffers and cache can easily be reclaimed for use by applications, the second line (-/+ buffers/cache) provides an indication of the memory actually used by applications (the "used" column) or available to applications (the "free" column). The sum of the memory used by buffers and cache reported in the first line is subtracted from the total used memory and added to the total free memory to give the two figures on the second line.
  • Swap space is generally used as a last resort when the system can't reclaim physical memory in other ways.
Another light hearted link is Help! Linux ate my RAM! That page has this table:

sf7ap3i4mu83x4z4g.jpg


The middle yellow bar above is referring to the buffers (91 mb) and cache (764 mb) values below (855 mb total).
Code:
$ free -m
             total       used       free     shared    buffers     cached
Mem:          1504       1491         13          0         91        764
-/+ buffers/cache:        635        [B][COLOR=Green]869[/COLOR][/B]
Swap:         2047          6       2041
869 mb is readily available and not just 13 mb!
So if you read that page, you'd know that 855 mb is NOT actually wasted, it's being used by linux to speed things up!

Basically, if you're not using the ram for apps, linux is using it for cache instead.
And when you need that ram for apps, you get to reclaim it instantly ;)

Therefore...

qa4h03xqltbb95e4g.jpg


======================================================

Ok that's all nice nice but why did I bother making a new tool?

Well, if you look at the first screen shot up top, you'll see that the android/busybox free command does NOT have the cached column.

Therefore, the free command on Android actually tells us a little something...
...but whole lotta nothing!

So, this is what I did about it...

g60d97cz48zw8c04g.jpg


Basically, I:

Added the cached colum
Removed the useless shared column (which is always 0 and is a waste of real estate)
Added the swap -/+ adjustment line (notice that 4076 kB is actually available, not just 16 kB)
Then total everything up nice nice ;)

So here's a direct comparison of the 2 outputs:

2dfxa1kmhr1uoxb4g.jpg


I added colour to the free output for easy comparison.

But notice how the -/+ adjustment line is COMPLETELY different.
The free command shows only 44,644 kB as being freely available but in reality, the value is 208,352 kB... not even close! Simply because free doesn't utilize the cached value (which is found /proc/meminfo along with all the other data.)

The math works both downwards... (add same colours to get the bold ie green plus green = green bold)
...and sideways ie. freely available(208352) = free(40104) + buffers(4540) + cached(163708)

Now, not everybody like rainbows so there is an alternate colour scheme...

oavootid2o1wg8y4g.jpg


Of course, while I was at it (it took me nearly a month to perfect it), I added a whole bunch of options...

a1d172soq63hl5s6g.jpg


So let's see it actually explain something with the -x option...

d2ux9qdr9vp9yjf6g.jpg


And explaing even more with -r... ( it's kinda like a mini tutorial ;) )

pecds83kact96ss6g.jpg
ms7n9v1e0vud9vd6g.jpg


Since it has so many options, it would be a pita to remember all the options so that you can have your favourite output format all the time...
So it will actually remember your last command (but ignores -help and -install).
Just type "freex" and it automagically does what you did last time...

49twn3kvialzn6e6g.jpg


The output is different depending on whether swap is enabled...

k42y4ywgsh1dw4o6g.jpg
zfdwzyk3d777mwp6g.jpg


I added the -o option from free which omits the -/+ adjustment line and added a -total only option...

gl0hacd391uoo7s6g.jpg
xwm3nu13l74347n6g.jpg


Force -wide option when not using kilobytes (and using a smaller font)...

g4d23pg3q8r13696g.jpg


It's nice to see the percentage table along with kB and/or mb tables.
Also note that it automatically uses wide output when using kB.

pe2iwvk9ighwmdi6g.jpg


Click the button for some gratuitous screen grabs...

r7pcy84dg9t5eyd6g.jpg


d1ny6ds6h34p66b6g.jpg
lwk9w3gh2j13wue6g.jpg


5vfafovh3bd8add6g.jpg
 

Attachments

  • Linux_Memory_Consumption_Real-Time_Embedded.pdf
    61.7 KB · Views: 975
Last edited:

zeppelinrox

Senior Member
Dec 21, 2010
9,374
21,590
IN THE FREAKIN' OP
Root is NOT required to use this script!

However, if not root, to actually install it for easy command line usage requires a little workaround.

Requirements:

1. An app that can run scripts lol

Fully compatible with Terminal Emulator and Script Manager/Script ManagerPro.
Other terminal apps probably won't display colours properly.
In fact Script Manager didn't either until I requested 256 colour support for it and @devwom updated it quite fast :)
So make sure to UPDATE Script Manager if that's your preference!

Tho it may not display all the colours, Terminal IDE will work too while installing BusyBox for itself.

2. BusyBox (for the grep and printf commands)

If you're rooted, then there is nothing else to do and go to the Install section.

If NOT rooted you have a few options.
a) download the attached busybox.zip and put it in the same place as the freex script. It is not a zip file. It's the busybox binary from Kbox2. I chose it for it's small size.
Just run freex as explained in the install section and freex will install "busybox.zip" for you as long as it's in the same location as the script.
b) install OneBox. It requires Terminal Emulator and automates the process to...
c) Install Kbox2
d) Easiest solution is probably BusyBox Non-Root but also for use with Terminal Emulator.
e) Use Terminal IDE (has its own BusyBox)

FreeXplain-r Installation:

(Pronounced "Free Explainer")

Note: Installation merely simplifies the execution of freex so that you can just type "freex" in your terminal app without having to type "sh /sdcard/freex*" all the time. Of course, if you're using a script runner like Script Manager, it doesn't matter too much since their purpose is to make it easy to run scripts.

1. Save attached script to sdcard. (No need to rename it from freex*.pdf)

2. Then just run the script!

If using Script Manager, no need for me to explain how to use that app.

If using a terminal app, do:
Code:
cd /sdcard
sh freex*
No need for the -i switch it should install automatically.

Use the -i switch for forced installation/update/refresh.

If not running as root, it will copy to your terminal app's data folder and give you further instructions.

nl112jv6yh3y38u6g.jpg


Notice that it says to run with "sh freex" in the help section?
That's because the $PATH statement hasn't yet been setup in the terminal app's settings.

If running as root, it will automatically install to /system/xbin and it's easy as pie.

ufar37e7w2q3a9a6g.jpg



Here is a forced refresh/reinstall.
Not running as root at first but the $PATH is setup so it doesn't give the additional help info to set that up.
Then as root, of course it installs to /system/xbin

buqsy02kzbvy7ob6g.jpg
 

Attachments

  • busybox.zip
    465.8 KB · Views: 431
  • freex_RC2.sh.pdf
    18.2 KB · Views: 1,623
Last edited:

eushaun99

Senior Member
Feb 8, 2013
2,014
970
25
Subang Jaya
Even for a simple(but not so simple :p) script you can explain this much. This really sums up what an amazing developer you are zep.

Sent from my GT-P7500 using Tapatalk
 
Last edited:
  • Like
Reactions: zeppelinrox

mrhnet

Senior Member
Jan 2, 2012
325
268
This is nice!! Explains all! I like rainbows of course.. ;)

Noted something.. when running (installing) the script saved to a folder which has a name with spaces, an error occurs (I'm using ScriptManager). "freex" didn't get installed to xbin properly (size=0). No issues otherwise.
4cU4enUl.jpg
 
Last edited:

zeppelinrox

Senior Member
Dec 21, 2010
9,374
21,590
IN THE FREAKIN' OP
Another masterpiece from the GoRM!
ok I give up... what's GoRM? IMMA N00B and forgot the URL for google.com :p

Even for a simple(but not so simple :p) script you can explain this much. This really sums up what an amazing developer you are zep.

Sent from my GT-P7500 using Tapatalk
I don't bother if it don't work on all devices ;)
This is nice!! Explains all! I like rainbows of course.. ;)

Noted something.. when running (installing) the script saved to a folder which has a name with spaces, an error occurs (I'm using ScriptManager). "freex" didn't get installed to xbin properly (size=0). No issues otherwise.
4cU4enUl.jpg
Ah the scripter's life long nemesis... the evil space in a folder name.

I shall quash that empty soul in our next duel.

Btw you didn't update Script Manager... the rainbow is all wrong lol

Edit: Added a poll. For fun, I'm gonna view it as an IQ test. heh.
 
Last edited:

eriknors

Senior Member
Nov 8, 2011
1,046
328
Hey zepp just wanted to confirm after running this script this is what my free ram should look like



sent from my DNA
 

Attachments

  • 1400626163517.jpg
    1400626163517.jpg
    49.5 KB · Views: 541

eriknors

Senior Member
Nov 8, 2011
1,046
328
Ok any idea as to why I'm getting this

sent from my DNA
 

Attachments

  • 1400646648493.jpg
    1400646648493.jpg
    119.4 KB · Views: 371

zeppelinrox

Senior Member
Dec 21, 2010
9,374
21,590
IN THE FREAKIN' OP
God of RAM Management :silly:
Oh right!
I'm too humble to have figured that one out lol
Yup.. noted that. I meant rainbows in terminal emulator..
IlPSvKrl.jpg


"watch freex" command lets me to enjoy the rainbows every 2 seconds :p
That's funny I was looking at other free options and thoughr about adding the interval option with -s and also saw that watch tip lol
But it clears the screen so it only shows the latest output.
Or this

sent from my DNA
what if you don't use exec? I just tried with exec and terminal emulator crashed.
 

eriknors

Senior Member
Nov 8, 2011
1,046
328
Oh right!
I'm too humble to have figured that one out lol

That's funny I was looking at other free options and thoughr about adding the interval option with -s and also saw that watch tip lol
But it clears the screen so it only shows the latest output.
what if you don't use exec? I just tried with exec and terminal emulator crashed.

I don't follow how else could I run it without exec? All I do is open terminal emulator type su then type freex

sent from my DNA
 

hhp_211

Senior Member
May 15, 2008
1,832
926
I don't follow how else could I run it without exec? All I do is open terminal emulator type su then type freex

sent from my DNA


I think you might be experiencing the issue related to this below::



mrhnet
Noted something.. when running (installing) the script saved to a folder which has a name with spaces, an error occurs ... "freex" didn't get installed to xbin properly (size=0). No issues otherwise.
4cU4enUl.jpg


zeppelinrox
Ah the scripter's life long nemesis... the evil space in a folder name.
I shall quash that empty soul in our next duel.


:::::::::::::::


move your downloaded ""freex_RC1.sh.pdf "" to just the /sdcard
::: I personally re-name it to ""freex_RC1.sh""

and then open terminal
give her the ole su command
and
Use the -i switch for forced installation/update/refresh.

:: sh /sdcard/freex_RC1.sh -i ::

Then as root, of course it installs to /system/xbin

buqsy02kzbvy7ob7g.jpg






Now run your commands...




.
 

eriknors

Senior Member
Nov 8, 2011
1,046
328
Ok I double checked where I have the file and its path is /sdcard/freex_RC1.sh no spaces. Did exactly what u suggested and when I try to run freex -i I get this. Could it have been installed to system/xbin incorrectly and now unless I either dirty flash my Rom or restore system it's not gonna change?

sent from my DNA
 

Attachments

  • 1400697441705.jpg
    1400697441705.jpg
    62.4 KB · Views: 176

zeppelinrox

Senior Member
Dec 21, 2010
9,374
21,590
IN THE FREAKIN' OP
Ok I double checked where I have the file and its path is /sdcard/freex_RC1.sh no spaces. Did exactly what u suggested and when I try to run freex -i I get this. Could it have been installed to system/xbin incorrectly and now unless I either dirty flash my Rom or restore system it's not gonna change?

sent from my DNA

Maybe you have an incomplete download
 

hhp_211

Senior Member
May 15, 2008
1,832
926
Ok I double checked where I have the file and its path is /sdcard/freex_RC1.sh no spaces. Did exactly what u suggested and when I try to run freex -i I get this. Could it have been installed to system/xbin incorrectly and now unless I either dirty flash my Rom or restore system it's not gonna change?

sent from my DNA
according to your photo you did not type the command properly

look at your command it should read this
:: sh /sdcard/freex_RC1.sh -i ::

that is a minus and lowercase letter i

that is what tells it to force re-install

you should then see it tell you

"installing myself to...
/system/xbin/feeex"

I'm not 100% sure but you may want to run it as su,
then the command

.
 

eriknors

Senior Member
Nov 8, 2011
1,046
328
according to your photo you did not type the command properly

look at your command it should read this
:: sh /sdcard/freex_RC1.sh -i ::

that is a minus and lowercase letter i

that is what tells it to force re-install

you should then see it tell you

"installing myself to...
/system/xbin/feeex"

I'm not 100% sure but you may want to run it as su,
then the command

.

I'm pretty sure zepp is right I'm gonna redownload it. I did run the exact command u are referring to I just didn't screenshot it. Who knows though knowing my luck the script probably isn't going to work correctly for my phone cause it's an HTC or for some random reason my kernel doesn't support something. I've always trusted @zepplinrox scripts and I've lived by V6 for as long as I can remember but even when I follow every step to a T I almost always run into these random isolated quirks. I mean everyone else that's ran this has had no issue yet I do exactly the same thing and for whatever reason the script runs but no info shows up? I will redownload and start from scratch and report back. Thanks again zepp. Can't wait for ur V6 kk edition

sent from my DNA
 

Top Liked Posts

  • There are no posts matching your filters.
  • 51
    [TOOL/SCRIPT/RC2]FreeXplain-r / freex-BETTER than free & Why "free" RAM ISN'T WASTED!

    See Post #2 for Installation/Requirements/Download.

    Now before getting into my new tool, I'd like to explain why I felt the need to even bother making it.

    First of all, if you've ever typed "free" in terminal, you'd see that it shows almost no free ram while any app you check with would show lots of free ram.

    This what it looks like.

    p2pzzt3rkti5xms6g.jpg


    Now if you're like me, you'd probably do a google search to figure out what the hell it means lol
    Because I had over 200 mb "free" when I took that screen shot but that shows only 40mb free and it would be nice if it actually made some sense ;)

    Some of you familiar with my V6 SuperCharger may have read this post of mine before: "Why 'Free RAM' Is NOT Wasted RAM!"
    In there, I post some findings from my first hand experience and how it correlates with this article Linux Memory Consumption (which I had found afterwards)
    Unfortunately, that page is now down but I had a saved copy in PDF format which I've attached.

    In that pdf, it reads "The absolute free memory number is not only the value of MemFree, but the sum of the MemFree, Buffers and Cached fields."

    There are many pages that can help you figure it out.
    Here is a good one Check Linux Memory Usage Using Free Command

    If you need to know exactly what buffers and cache actually are, click the button
    Info taken from http://nilesh-joshi.blogspot.ca/2010/04/interpreting-output-of-free-command.html


    • The "buffers" column shows the amount of memory being used by the kernel buffer cache. The buffer cache is used to speed up disk operations, by allowing disk reads and writes to be serviced directly from memory. The buffer cache size will increase or decrease as memory usage on the system changes; this memory is reclaimed if it is needed by applications.
    • The "cache" column indicates how many memory pages the kernel has cached for faster access later. Since the memory used for buffers and cache can easily be reclaimed for use by applications, the second line (-/+ buffers/cache) provides an indication of the memory actually used by applications (the "used" column) or available to applications (the "free" column). The sum of the memory used by buffers and cache reported in the first line is subtracted from the total used memory and added to the total free memory to give the two figures on the second line.
    • Swap space is generally used as a last resort when the system can't reclaim physical memory in other ways.
    Another light hearted link is Help! Linux ate my RAM! That page has this table:

    sf7ap3i4mu83x4z4g.jpg


    The middle yellow bar above is referring to the buffers (91 mb) and cache (764 mb) values below (855 mb total).
    Code:
    $ free -m
                 total       used       free     shared    buffers     cached
    Mem:          1504       1491         13          0         91        764
    -/+ buffers/cache:        635        [B][COLOR=Green]869[/COLOR][/B]
    Swap:         2047          6       2041
    869 mb is readily available and not just 13 mb!
    So if you read that page, you'd know that 855 mb is NOT actually wasted, it's being used by linux to speed things up!

    Basically, if you're not using the ram for apps, linux is using it for cache instead.
    And when you need that ram for apps, you get to reclaim it instantly ;)

    Therefore...

    qa4h03xqltbb95e4g.jpg


    ======================================================

    Ok that's all nice nice but why did I bother making a new tool?

    Well, if you look at the first screen shot up top, you'll see that the android/busybox free command does NOT have the cached column.

    Therefore, the free command on Android actually tells us a little something...
    ...but whole lotta nothing!

    So, this is what I did about it...

    g60d97cz48zw8c04g.jpg


    Basically, I:

    Added the cached colum
    Removed the useless shared column (which is always 0 and is a waste of real estate)
    Added the swap -/+ adjustment line (notice that 4076 kB is actually available, not just 16 kB)
    Then total everything up nice nice ;)

    So here's a direct comparison of the 2 outputs:

    2dfxa1kmhr1uoxb4g.jpg


    I added colour to the free output for easy comparison.

    But notice how the -/+ adjustment line is COMPLETELY different.
    The free command shows only 44,644 kB as being freely available but in reality, the value is 208,352 kB... not even close! Simply because free doesn't utilize the cached value (which is found /proc/meminfo along with all the other data.)

    The math works both downwards... (add same colours to get the bold ie green plus green = green bold)
    ...and sideways ie. freely available(208352) = free(40104) + buffers(4540) + cached(163708)

    Now, not everybody like rainbows so there is an alternate colour scheme...

    oavootid2o1wg8y4g.jpg


    Of course, while I was at it (it took me nearly a month to perfect it), I added a whole bunch of options...

    a1d172soq63hl5s6g.jpg


    So let's see it actually explain something with the -x option...

    d2ux9qdr9vp9yjf6g.jpg


    And explaing even more with -r... ( it's kinda like a mini tutorial ;) )

    pecds83kact96ss6g.jpg
    ms7n9v1e0vud9vd6g.jpg


    Since it has so many options, it would be a pita to remember all the options so that you can have your favourite output format all the time...
    So it will actually remember your last command (but ignores -help and -install).
    Just type "freex" and it automagically does what you did last time...

    49twn3kvialzn6e6g.jpg


    The output is different depending on whether swap is enabled...

    k42y4ywgsh1dw4o6g.jpg
    zfdwzyk3d777mwp6g.jpg


    I added the -o option from free which omits the -/+ adjustment line and added a -total only option...

    gl0hacd391uoo7s6g.jpg
    xwm3nu13l74347n6g.jpg


    Force -wide option when not using kilobytes (and using a smaller font)...

    g4d23pg3q8r13696g.jpg


    It's nice to see the percentage table along with kB and/or mb tables.
    Also note that it automatically uses wide output when using kB.

    pe2iwvk9ighwmdi6g.jpg


    Click the button for some gratuitous screen grabs...

    r7pcy84dg9t5eyd6g.jpg


    d1ny6ds6h34p66b6g.jpg
    lwk9w3gh2j13wue6g.jpg


    5vfafovh3bd8add6g.jpg
    29
    Root is NOT required to use this script!

    However, if not root, to actually install it for easy command line usage requires a little workaround.

    Requirements:

    1. An app that can run scripts lol

    Fully compatible with Terminal Emulator and Script Manager/Script ManagerPro.
    Other terminal apps probably won't display colours properly.
    In fact Script Manager didn't either until I requested 256 colour support for it and @devwom updated it quite fast :)
    So make sure to UPDATE Script Manager if that's your preference!

    Tho it may not display all the colours, Terminal IDE will work too while installing BusyBox for itself.

    2. BusyBox (for the grep and printf commands)

    If you're rooted, then there is nothing else to do and go to the Install section.

    If NOT rooted you have a few options.
    a) download the attached busybox.zip and put it in the same place as the freex script. It is not a zip file. It's the busybox binary from Kbox2. I chose it for it's small size.
    Just run freex as explained in the install section and freex will install "busybox.zip" for you as long as it's in the same location as the script.
    b) install OneBox. It requires Terminal Emulator and automates the process to...
    c) Install Kbox2
    d) Easiest solution is probably BusyBox Non-Root but also for use with Terminal Emulator.
    e) Use Terminal IDE (has its own BusyBox)

    FreeXplain-r Installation:

    (Pronounced "Free Explainer")

    Note: Installation merely simplifies the execution of freex so that you can just type "freex" in your terminal app without having to type "sh /sdcard/freex*" all the time. Of course, if you're using a script runner like Script Manager, it doesn't matter too much since their purpose is to make it easy to run scripts.

    1. Save attached script to sdcard. (No need to rename it from freex*.pdf)

    2. Then just run the script!

    If using Script Manager, no need for me to explain how to use that app.

    If using a terminal app, do:
    Code:
    cd /sdcard
    sh freex*
    No need for the -i switch it should install automatically.

    Use the -i switch for forced installation/update/refresh.

    If not running as root, it will copy to your terminal app's data folder and give you further instructions.

    nl112jv6yh3y38u6g.jpg


    Notice that it says to run with "sh freex" in the help section?
    That's because the $PATH statement hasn't yet been setup in the terminal app's settings.

    If running as root, it will automatically install to /system/xbin and it's easy as pie.

    ufar37e7w2q3a9a6g.jpg



    Here is a forced refresh/reinstall.
    Not running as root at first but the $PATH is setup so it doesn't give the additional help info to set that up.
    Then as root, of course it installs to /system/xbin

    buqsy02kzbvy7ob6g.jpg
    4
    RC2 bugfix is up!
    Updated OP and Post 2.
    2
    This is nice!! Explains all! I like rainbows of course.. ;)

    Noted something.. when running (installing) the script saved to a folder which has a name with spaces, an error occurs (I'm using ScriptManager). "freex" didn't get installed to xbin properly (size=0). No issues otherwise.
    4cU4enUl.jpg
    2
    Another masterpiece from the GoRM!
    ok I give up... what's GoRM? IMMA N00B and forgot the URL for google.com :p

    Even for a simple(but not so simple :p) script you can explain this much. This really sums up what an amazing developer you are zep.

    Sent from my GT-P7500 using Tapatalk
    I don't bother if it don't work on all devices ;)
    This is nice!! Explains all! I like rainbows of course.. ;)

    Noted something.. when running (installing) the script saved to a folder which has a name with spaces, an error occurs (I'm using ScriptManager). "freex" didn't get installed to xbin properly (size=0). No issues otherwise.
    4cU4enUl.jpg
    Ah the scripter's life long nemesis... the evil space in a folder name.

    I shall quash that empty soul in our next duel.

    Btw you didn't update Script Manager... the rainbow is all wrong lol

    Edit: Added a poll. For fun, I'm gonna view it as an IQ test. heh.