Memory management


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Memory management
# 1  
Old 10-04-2012
Data Memory management

Hello all.

I have a script that uses two arrays in the beginning. Saves certain values that i am extracting from df -h command.
array1[i] and array2[i] where i is from 0 to 9.

It then goes on and saves the values of the arrays into variables.

for i 0 to 9 , tmp= array2[i] // I am no writing the exact syntax here. just telling u my idea.

No I want the script to run again , get the latest results into my arrays and compare them with the values I had the last time saved in tmp. Will my previous values been in tmp variables? Im not sure on how memory management works in unix.

thanks
# 2  
Old 10-04-2012
Quote:
Originally Posted by Junaid Subhani
Will my previous values been in tmp variables? Im not sure on how memory management works in unix.
A "shell" is a program like any. A "shell script" is a text file with commands the shell program can read, understand and execute.

Memory management in Unix is equal to all the other OSes out there insofar as programs which end release their memory back to the OS. If every invocation of a software would come up in the same status it had when it ended a program crashing could never be restarted because it would come up in the same crashed state as it exited, no?

If you want to maintain your values write them down to a file and test for the existence of this file upon startup and fill your arrays from reading this file if it exists.

I hope this helps.

bakunin
This User Gave Thanks to bakunin For This Post:
# 3  
Old 10-04-2012
if you don't have any problem create another array.
because saving in temp variable, it saves only one value as per your variable assignment.

try something like this..

Code:
for i in {1..5}
do
temp[$i]=${array2[$i]}
done

then you can compare those with new value of arrays..
This User Gave Thanks to pamu For This Post:
# 4  
Old 10-04-2012
Thanks. Will the values in temp array be stored once I run the script again ?
# 5  
Old 10-04-2012
Quote:
Originally Posted by Junaid Subhani
Will the values in temp array be stored once I run the script again ?
I think bakunin already answered your question..

Quote:
Originally Posted by bakunin
If you want to maintain your values write them down to a file and test for the existence of this file upon startup and fill your arrays from reading this file if it exists.
that is better one. it doesn't impact your session expiry's and all. it can be worked even in another session and from another machine...

As my knowledge... shell variables and array are present till the session exists and for that session only..... Smilie

Hope this helps you..Smilie
This User Gave Thanks to pamu For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Efficient UNIX Memory management for Running MapReduce Jobs.

We are trying to set up a single node cloudera hadoop cluster having 16 GB as RAM on linux machine. We are setting up 5.4.2 version. Now when we check statistics post the installation and run the top command we find that only 1 -2 GB is available. when we trigger map reduce sample job - no... (2 Replies)
Discussion started by: ketankirange
2 Replies

2. Solaris

Solaris 10 - memory management confusion

Hello i have a Problem - my Server is running with following MEM Information (from TOP): Memory: 32G phys mem, 4195M free mem, 10G total swap, 9788M free swap So i think - no problem, 4GB Free, not swapin. So - our programmer wants to know what process taking how much memory - i... (5 Replies)
Discussion started by: roorbacj
5 Replies

3. UNIX for Advanced & Expert Users

kde memory management

Hi everyone! I am running KDE 3.5 on a Slackware 12.1 with 1.5Gb of RAM and have the following question: Running ps on regular intervals of 1 min, I see that 1.3Gb of RAM are being used, leaving me with 0.2Gb of free memory. I tried locating the most greedy app running, which was Kontact and... (0 Replies)
Discussion started by: kerb41
0 Replies

4. Solaris

Memory management in zones

whats the difference between setting zone capped-memory from zoncfg and setting rctl: name: zone.max-locked-memory .. if changed the zone.max-locked-memory with prctl it does not change in rcapstat .. but if change with rcapadm it reflects in rcapstat o/p (0 Replies)
Discussion started by: fugitive
0 Replies

5. UNIX for Advanced & Expert Users

virtual memory management, swapping paging

can anybody explain me the concepts virtual memory mangement, swapping and paging? although i roughly know what they are , i need more solid distinction between them, and also i want to figure out the relations between them? do you have any well-defined definitons for this concepts? (2 Replies)
Discussion started by: gfhgfnhhn
2 Replies

6. Programming

Programming for Memory Management

Hi I am relatively new to programming on UNIX platform. I was wondering if there is any system call so that a process can access systems page table or swap pages from main memory by specifying the page number. I am trying to implement various page replacement algorithms like LRU, OPT, FIFO etc.... (1 Reply)
Discussion started by: jayesch
1 Replies

7. UNIX for Advanced & Expert Users

unix memory management

i am looking for the books or web-sites which explains the unix memory management in detail. do you know any useful material? (1 Reply)
Discussion started by: gfhgfnhhn
1 Replies
Login or Register to Ask a Question