Operating System - HP-UX
1833431 Members
3490 Online
110052 Solutions
New Discussion

Re: Clearing and Releasing Buffer Cache

 
Chuck Lackey
Advisor

Clearing and Releasing Buffer Cache

After a night of software compiles, Glance shows 99% memory allocation because most of RAM has been claimed as buffer cache and it holds until release is requested by another process.

Is there a utility to force release of buffer cache, thus clearing its contents giving a realistic reading of actual memory in use? We're trying to troubleshoot some memory leaks in code.

Thanks,
Chuck Lackey
9 REPLIES 9
Rick Garland
Honored Contributor

Re: Clearing and Releasing Buffer Cache

Sounds as if you are looking for the ipcrm command.

Use the ipcs command to get the info needed and then you can remove via ipcrm
James R. Ferguson
Acclaimed Contributor

Re: Clearing and Releasing Buffer Cache

Chuck:

I agree with Rick's suggestion. You might also try 'sync', although I'm not sure that this is going to actually free memory if there is no pressure to overlay.

...JRF...
Tim Malnati
Honored Contributor

Re: Clearing and Releasing Buffer Cache

The sync command will do little to help you where all it does is flush dirty bits to disk; buffer cache size is not changed. Actually the syncer does the same thing every 30 seconds and a bdf command invokes a sync prior to output. ipcrm will clean out shared memory segments, but a lot depends on how much shared memory was actually used. Sorry, no command that I know of to actually release buffer cache. When your system nears 100% the os will discard it for user processes, but it will take it back as the user memory resource need decreases.

It appears that you will need to retune the kernel a little bit in order to prevent buffer cache from growing this large during your testing. The default kernel sets up the minimum buffer cache at 10% (dbc_min_pct) and can normally grow up to 50% (dbc_max_pct). I hope this is a test machine. I would reset these to allow enough room for your core processes, recompile the kernel and reboot. Your not talking about anything time consuming here - ten minutes to rebuild plus boot time. After you are done, save this kernel setup for future testing and move back the old one and reboot again.

I don't have Glance documentation handy, but I believe the metrics are there to track buffer cache utilization along with the memory eaten up by your problem processes. GUI Glance (gpm) is excellent when it comes to monitoring individual processes and their resource needs.

Hope this helps.
Anthony deRito
Respected Contributor

Re: Clearing and Releasing Buffer Cache

You cannot force buffer cache to release pages of memory. This is the job of the page reclaimer (vhand). Removing shared memory segments can really start screwing your applications up if you start removing things you should not. Tune your system's memory according to what is best to your application(s). Reducing the size of your buffer cache may be a good idea. Before you do this, you will want to run the command "sar -d" to determine your buffer cache hit ratio on reads and writes. If you see 80% - 100% hit ratios then you can afford to reduce the size of your buffer cache by tuning dbc_min_pct and dbc_max_pct. Remember that your buffer cache will shrink and grow depending on the memory pressure of your system. If your virtual memory subsystem needs to start reclaiming pages (by way of vhand), the buffer cache will shrink. It takes time for the page reclaim to occur so you will not see a sudden drop in size.

Also, you should keep an eye on your virtual memory pagout activities. Use vmstat to indicate to you if you are at the point of deactivating processes and swapping out pages of memory.

If your trying to detect memory leaks, what would help is to use the process list window of Glance and view the "Res Memory" and the "Virtual memory" fileds of your processes. This would indicate which processes may have a memory leak. If there was a memory leak, you would see the values increasing.

Tony
Carlos Fernandez Riera
Honored Contributor

Re: Clearing and Releasing Buffer Cache

Buffer chache size is configured on kernel parameters dbc_max_pct and dbc_min_pct.

Its very usual dbc_max_pct to be 50% of memory.

Reconfigure your kernel
dbc_max_pct=10# or 5, depending on your memory size ( 1Gb * 50% = 500Mb of memory cache).
unsupported
Darrel Louis
Honored Contributor

Re: Clearing and Releasing Buffer Cache

Hi,

Check the following url:
http://www.docs.hp.com//hpux/onlinedocs/os/KCparams.OverviewAll.html

Configurable File System Buffer-Cache Parameters:

bufpages
Pages of static buffer cache
dbc_min_pct
Minimum dynamic buffer cache
dbc_max_pct
Maximum dynamic buffer cache
nbuf
Number of static buffer headers

When you've a Database, like Oracle, I would recommend to make use of Dynamic Buffer Cache.
Bring dbc_max_pct and dbc_min_pct close or equal to each other (5 ; 2 %)
Make nbuf and bufpages 0.

This is all described in the url above.
Anthony deRito
Respected Contributor

Re: Clearing and Releasing Buffer Cache

Darrell, keep in mind that buffer cache is not used when performing raw I/O data transfers. If Oracle is using the block I/O then your comment about using buffer cache with Oracle would be true.

Tony
Bill McNAMARA_1
Honored Contributor

Re: Clearing and Releasing Buffer Cache

Have a closer look at how your filesystems
are mounted too. You can play with buffering
parameter here too.

Bill
It works for me (tm)
Jim Welch
Respected Contributor

Re: Clearing and Releasing Buffer Cache

If I were going to look for memory leaks, I would first set dbc_max_pct and dbc_min_pct to the same value and reboot so that it would be easier to see changes in memory usage without buffer cache changes clouding the issue.
Any sufficiently advanced technology is indistinguishable from Magic - Arthur C. Clarke