Link to home
Start Free TrialLog in
Avatar of SachinDesai
SachinDesai

asked on

How to free up unused cache or memory space

Hi ,
 
 I have a routine process which includes several bash scripts , perl programs and
other compiled programs which utilize a lot of memory. ( takes almost 32 hours to run )
 Initially the process runs as expected , but after say 10 hours , i can see that the speed of processing has gone down drastically. I mean when i do a 'ps' i can see that the current script is utilizing only 1.6% CPU and takes hours to complete. Whereas if i run the same script alone , It utilizes sizable memory ( 95% CPU ) and completes within 15 minutes.
 I guess i may have got some memory stuck or blocked ....
I have.....
RAM:1023 MB
SWAP : 3892 MB
OS : SunOS Release 5.8 Generic_108529-13

Ouestion: How do I release the memory without stopping the process or from within the process ( bashscript ) ? and also please note that I am not the Administrator.Any other related suggestions are also welcome.

 
ASKER CERTIFIED SOLUTION
Avatar of shivsa
shivsa
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of glassd
glassd

I'm a little confused.

> It utilizes sizable memory ( 95% CPU )
Memory and CPU are different entities. Just because it uses 95% CPU does not mean it uses lots of memory.

What I think you need to do is monitor the process throughout its life, recording the main system attributes during that period.

The first port of call is usually sar. There are heaps of parameters to sar, but run without any it will record the proportion of time the system is being used by usr and sys and the proportion spent waiting for io. Running it like this:
   sar 60 1000 > sar.out
will run the reporting every 60 seconds for 1000 cycles (ie it will report once every 60 secs for 1000 minutes) and will output to file "logfile".

Have a look at the man page for sar for an explanation of the output.

If the CPU use goes right down, but the process still continues running, it could be that you are out of memory and starting to swap. Look at the paging stats from vmstat. As before:
   vmstat 60 1000 > vmstat.out
The columns to look at are:
   free   free memory pages
   swap   free pages in swap
   sr  scan rate - indicates that the system is scanning memory for pages to move out into swap
   po  page out - pages being moved to swap

There are other tools available, for example prstat and mpstat. Take a look and see haow you get on.
Just to clarify something shivsa said. The file cache will occupy almost all free memory after the system has been in use for some time. However this is still effectively free memory, and so will be used by processes as they need it. There is no need to force it to be free.

At some stage (not sure if it is Solaris 8 or 9) the free memory reporting has been changed so that it counts file cache as free memory.
Avatar of yuzh
As already mentioned in the about comments, you can not use script to FREE
process memory. "u may use good programming technique for memory management(free() up all the memory in code after using that and all).

Have a look at the following Solaris memory management doc:
http://tyrant112.tripod.com/overbeck/SolarisMem.htm

and

UNIX FAQ: -- Virtual Memory

     http://argray.org/unixfaq/explain_vm.shtml

Performance tune:
http://oldlook.experts-exchange.com/questions/20498241/Solaris-8-Performance-Tuning.html
   
Hi Sachin.
do u need more help here. please keep posted.
Sachin,
You can close the question by following this guidelines:

https://www.experts-exchange.com/help.jsp#hs5