Go Down

Topic: Some question about memory on the Linino side (Read 821 times) previous topic - next topic

speaking

Apr 18, 2014, 06:50 pm Last Edit: Apr 18, 2014, 07:04 pm by speaking Reason: 1
In my Python scripts (that are periodically triggered by the Arduino side) I use and run code as-like the following:

Code: [Select]

import os

os.system curl www.website.com --output /tmp/script_file.txt

# ...

with open('/tmp/script_file.txt') as file1:
   content = ... # load content

#...

file2 = open('/tmp/another_script_file.txt', 'w')

#...



My questions are:

1) Can the above code make the Linino side to reach "out of memory" / "stackoverflow" errors so that it starts to behave unespectly or even to block "a là Arduino way"?

2) Is it advisable to store the cURL response (see the '--output' option in the above code) to files in the 'tmp' directory on the Linino side?

3) What should I look for in order to avoid issues?

4) What else do you advice relating memory concerns on the Linino side?

5) What tools should I use to monitor the memory usage on the Linino side?

noblepepper


1) Can the above code make the Linino side to reach "out of memory" / "stackoverflow" errors so that it starts to behave unespectly or even to block "a là Arduino way"?

I can't say for sure, but probably the answer is "sure you can use up all the ram". If you do the result will probably be a "Out of memory" kernel panic.
Quote

2) Is it advisable to store the cURL response (see the '--output' option in the above code) to files in the 'tmp' directory on the Linino side?

It is as good a place as any. Definitely better than flash. /tmp is in ram.
A sd card or thumb drive that you don't mind burning all the write cycles on may be another good place especially if you have a LOT of info to store and don't write it often.

Quote

3) What should I look for in order to avoid issues?

4) What else do you advice relating memory concerns on the Linino side?

Use as little as possible, there is only 64M. Flush unused information often. Have your scripts that store a lot of information check to see how much they are using/is available

Quote

5) What tools should I use to monitor the memory usage on the Linino side?

Linino is a version of Openwrt, Openwrt is a version of linux. The normal tools for linux are (usually) available.
Code: [Select]
root@Arduino:~# free
             total         used         free       shared      buffers
Mem:         61132        27968        33164            0         3844
-/+ buffers:              24124        37008
Swap:            0            0            0
root@Arduino:~# cat /proc/meminfo
MemTotal:          61132 kB
MemFree:           33164 kB
Buffers:            3844 kB
Cached:             9832 kB
SwapCached:            0 kB
Active:             7828 kB
Inactive:           8252 kB
Active(anon):       2452 kB
Inactive(anon):       72 kB
Active(file):       5376 kB
Inactive(file):     8180 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:             0 kB
SwapFree:              0 kB
Dirty:                 0 kB
Writeback:             0 kB
AnonPages:          2420 kB
Mapped:             2528 kB
Shmem:               120 kB
Slab:               5348 kB
SReclaimable:       1320 kB
SUnreclaim:         4028 kB
KernelStack:         376 kB
PageTables:          380 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:       30564 kB
Committed_AS:       7332 kB
VmallocTotal:    1048372 kB
VmallocUsed:        2404 kB
VmallocChunk:    1038528 kB


Go Up