From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10650a,4ebc0ddaaccff248 X-Google-Attributes: gid10650a,public X-Google-Thread: fee84,4ebc0ddaaccff248 X-Google-Attributes: gidfee84,public From: nospam@zk3.dec.com (Eric Werme - replace nospam with werme) Subject: Re: How to clear UBC (unified buffer cache)? Date: 1999/08/02 Message-ID: <7o4oti$khl$1@nntpd.lkg.dec.com>#1/1 X-Deja-AN: 508056453 References: <379cd2eb@rcfnews.cs.umass.edu> Organization: Digital Equipment Corporation Reply-To: (Replace nobody with werme) nobody@zk3.dec.com Newsgroups: comp.unix.osf.osf1,comp.unix.internals "Karl" writes: >Is there a way to programmatically (or *any* way) clear the UBC (Unified >Buffer Cache)? Is there a way to clear the metadata buffer cache? >Rebooting the system or re-mounting the filesystem are not practical >options. Try this snippet from the Connectathon testsuite (www.connectathon.org): #define MMAP #ifdef MMAP #include #endif #ifdef MMAP caddr_t maddr; #endif #ifdef MMAP maddr = mmap((caddr_t)0, (size_t)size, PROT_READ, MAP_PRIVATE, fd, (off_t)0); if (maddr == NULL) { error("can't mmap '%s'", bigfile); exit(1); } if (msync(maddr, (size_t)size, MS_INVALIDATE) < 0) { error("can't invalidate pages for '%s'", bigfile); exit(1); } if (munmap(maddr, (size_t)size) < 0) { error("can't munmap '%s'", bigfile); exit(1); } #endif No guarantees that it works on all past or future releases or all file systems. It does work on NFS. (But no guaranteess it will continue to do so.) It invalidates the cache for the file descriptor fd, not for the whole FS. -Ric Werme -- <> Eric (Ric) Werme <> The above is unlikely to contain <> <> ROT-13 addresses: <> official claims or policies of <> <> <> Compaq Computer Corp. <> <> <> http://www.cyberportal.net/werme <>