[MPlayer-users] [Patch] Disable file syatem driver cache
Tom Evans
tevans.uk at googlemail.com
Fri Dec 16 11:03:42 CET 2011
On Fri, Dec 16, 2011 at 2:38 AM, Zongyao Qu <zongyao.qu at gmail.com> wrote:
> Sorry I don't know how to post a attachment,
> so I copy-paste the content in the post.
>
>
> --- /Temp/str407A.tmp/stream_file-745838-left.c
> Fri Dec 16 11:18:15 2011
> +++ /Develop/mplayer-for-MPlayerX/stream/stream_file.c
> Fri Dec 16 11:15:40 2011
> @@ -175,6 +175,10 @@
> m_struct_free(&stream_opts,opts);
> return STREAM_ERROR;
> }
> + // turn os file caching off
> + fcntl( f, F_NOCACHE, 1 );
> + // enable read ahead
> + fcntl( f, F_RDAHEAD, 1 );
> }
>
> len=lseek(f,0,SEEK_END); lseek(f,0,SEEK_SET);
>
> [ This patch is especially useful for Mac OSX, but I am
> not sure how about Linux and other OSs. ]
I have no idea whether this is the right thing to do on OS X, but it
cannot go in like this, as both F_NOCACHE and F_RDAHEAD are OS X
extensions.
F_RDAHEAD is also in FreeBSD, where we also have F_READAHEAD from
Linux, although the two have slightly different behaviour - F_RDAHEAD
allows you to enable/disable a 128kb read-ahead, where as F_READAHEAD
allows you to specify the read-ahead size.
The equivalent to F_NOCACHE on other systems is posix_fadvise(…,
POSIX_FADV_DONTNEED), although again, some OS - most BSDs - don't have
that either.
>
> In Mac, the driver will fill the unused memory
> for caching, by default.
>
> So if a huge file(1080P, etc) is played, driver will
> use up all the memory, and if there are other apps ask
> for memory, page swap will happen.
>
> This is not a leak, but it seams driver won't release
> that cache, until I reboot it, or unmount the
> volume in which the cached media file is.
>
It's not held, or at least not directly. The OS will report cached
memory in Inactive memory, and will release it as soon as there is VM
pressure on inactive memory. In general, OS X and FreeBSD will try to
use any RAM that is not being used for file system caching.
Cheers
Tom
More information about the MPlayer-users
mailing list