09-07-2016 02:23 AM
Hello,
I want to run 'echo 3 > /proc/sys/vm/drop_caches' on LabVIEW by System Exec.vi.
When I creat many log or picture files, system freeze sometimes because there is not enough 'free memory'.
So, I tried 'drop_caches' but, LabVIEW reply 'Permission denied' as standard error.
I aleady know that drop_caches is -rw---r---r---.
I found some solutions like follows,
(1) sudo sh -c "echo 3 > ./proc/sys/vm/drop_caches"
(2) echo 3 | sudo tee /proc/sys/vm/drop_caches
But there things are good at SSH not 'LabVIEW System Exec.vi'.
LabVIEW just reply 'sudo: tee: command not found' or 'sudo: sh: command not found'. as standard error.
Regards,
Seyong
09-07-2016 08:59 AM
The sudo approach is correct. Dropping caches is a priviledged operation that requires admin(root) access.
'sh' and 'tee' are contained in the base image so my guess is you are missing the 'sudo' command which is not installed by default.
To install sudo, run (in a ssh or serial shell):
opkg update
opkg install sudo
However I think dropping caches is just a workaround which might work for a while but it can still run out of memory with bad consequeces (most likely LabVIEW will get killed by the OOM killer). You should try to re-architect your application to flush the picture/log files directly or find other ways to reduce memory usage.
09-09-2016 12:52 AM
I installed 'sudo' already.
I found out memory information by using '#cat /proc/meminfo'.
My problem is that the Cached / SReclaimable is too big and the MemFree is too small(about 6MB and stay about 6MB).
We are using SOM and logging many days(3 days or more).
The Cached memory increase, when I create or write a new logging file.
Data buffers (for FIFO, Array and so on) are fixed on LabVIEW program.
I think 'drop_caches' is best solution for cached memory recover.
When I use 'lvuser@...$sudo echo 3 > /proc/sys/vm/drop_caches' on SSH teminal, 'sudo' run for just 'echo' not 'drop_caches'.
The 'echo' can not write value to 'drop_caches' because the permission of drop_caches is -rw--r--r--.
"lvuser@.....$echo 3 | sudo tee /proc/sys/vm/drop_caches" is solution of permission problem.
After #su lvuser, I can run "lvuser@.....$echo3 | tee /proc/sys/vm/drop_caches' on SSH terminal and Linux x windows terminal.
(Please refer to attached 'on SSH.png'. I/O error is not matter.)
But, I can not run on LabVIEW System Exec.vi.(Please refer to 'on LabVIEW.png).
It returns "sudo: tee: command not found' standard error.
Regards,
-----------
I attached my /etc/sudoers too.
09-09-2016 01:40 AM
Thanks gratian.crisan.
I found the solution.
echo 3 | sudo -i tee /proc/sys/vm/drop_caches
is good.
You can use initialize code with 'chmod' about 'USB serial port problem'
sudo -i /bin/chmod o+rw /dev/ttyUSB0
regards,
09-09-2016 08:55 AM
My problem is that the Cached / SReclaimable is too big and the MemFree is too small(about 6MB and stay about 6MB).
Having a lot of Cached/SReclaimable memory (and a small amount of MemFree) is not normally a problem and does not indicate that your system is running out of memory (see https://linux-mm.org/Low_On_Memory and https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=34e431b0ae398fc54ea69ff85... and similar information for details).
When I creat many log or picture files, system freeze sometimes because there is not enough 'free memory'.
As Gratian noted, if you really are running out of memory, drop_caches isn't going to solve the problem long term (honestly I'd be a little surprised if it helps much at all -- the system should already be reclaiming that memory if it's needed and is possible to reclaim). Can you give more details on the symptoms you're seeing? Where does it report that there is not enough free memory?