Solved

How to free up unused cache or memory space

Posted on 2003-11-18
7
1,029 Views
Last Modified: 2013-12-27
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.

 
0
Comment
Question by:SachinDesai
  • 4
  • 2
7 Comments
 
LVL 24

Accepted Solution

by:
shivsa earned 125 total points
ID: 9776873
In first case, your system is stress and starving for memory.
=======================================

The application code and its data files are still in memory, even though they are not active. The memory they occupy is not "free." since the same application running it finds the pages that are already in memory and not able to free. and there is insufficient free memory for any new process.

when u start a alone new process the kernel will scan for pages that have not been touched for a long time, and "free" them. Once you quit the first application, the memory it occupies is not being touched, so it will be freed quickly for use by other applications.

In 1988, Sun introduced this feature in SunOS 4.0. It still applies to all versions of Solaris 1 and 2. The kernel is trying to avoid disk reads by caching as many files as possible in memory. Attaching to a page in memory is around 1,000 times faster than reading it in from disk. The kernel figures that you paid good money for all of that RAM, so it will try to make good use of it by retaining files you might need.

===========
So short answer that u can not free up memory while running the process. u may use good programming technique for memory management(like free up all the memory in code after using that and all).
u may also check your programs for possible memory leaks.
0
 
LVL 24

Expert Comment

by:shivsa
ID: 9776875
0
 
LVL 7

Expert Comment

by:glassd
ID: 9776916
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.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 7

Expert Comment

by:glassd
ID: 9776933
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.
0
 
LVL 38

Expert Comment

by:yuzh
ID: 9776982
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/Operating_Systems/Solaris/Q_20498241.html
   
0
 
LVL 24

Expert Comment

by:shivsa
ID: 9783825
Hi Sachin.
do u need more help here. please keep posted.
0
 
LVL 24

Expert Comment

by:shivsa
ID: 9816358
Sachin,
You can close the question by following this guidelines:

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

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now