Go Premium for a chance to win a PS4. Enter to Win


How to free up unused cache or memory space

Posted on 2003-11-18
Medium Priority
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.

Question by:SachinDesai
  • 4
  • 2
LVL 24

Accepted Solution

shivsa earned 250 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.
LVL 24

Expert Comment

ID: 9776875

Expert Comment

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.
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Expert Comment

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.
LVL 38

Expert Comment

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:


UNIX FAQ: -- Virtual Memory


Performance tune:
LVL 24

Expert Comment

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

Expert Comment

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


Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
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.
Suggested Courses

783 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