page cache query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dear list members,

I have a question about Linux page cache. I create a 10MB file using
following application code:

int fd=open("foo.txt", O_CREAT|O_RDWR|O_SYNC);
char* content=(char *)malloc(1024*1024*10);
write(fd, content, 1024*1024*10);
free(content); close(fd);

Immediately before and after this code execution, command "free -m"
shows free memory decreased by 10M and cache incresed by 10M.

If I delete foo.txt, then free memory increases by 10M and cache
decreases by 10M.

My question is why the cache is growing even after O_SYNC flag? Even
fsync does not help. But deleting file freeing the cache.

Is there any way to free cache?

I am using RHEL3 (2.4.21-40 kernel) and /proc/sys/vm/ has following
configuration:

/proc/sys/vm/bdflush:50 500     0       0       500     3000    80
 50      0
/proc/sys/vm/dcache_priority:0
/proc/sys/vm/hugetlb_pool:0
/proc/sys/vm/inactive_clean_percent:30
/proc/sys/vm/kscand_work_percent:100
/proc/sys/vm/kswapd:512 32      8
/proc/sys/vm/max-readahead:31
/proc/sys/vm/max_map_count:65536
/proc/sys/vm/min-readahead:3
/proc/sys/vm/oom-kill:1
/proc/sys/vm/overcommit_memory:0
/proc/sys/vm/overcommit_ratio:50
/proc/sys/vm/page-cluster:3
/proc/sys/vm/pagecache:1        15      30
/proc/sys/vm/pagetable_cache:25 50
/proc/sys/vm/skip_mapped_pages:0
/proc/sys/vm/stack_defer_threshold:2048
/proc/sys/vm/vm-defragment:0

Thanks
Lal

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux