.TH freemem "" "" "Device"
.PC "Device that indicates amount of memory that is free"
.B /dev/freemem
.PP
.II "kernel^free memory"
.II "memory, free, estimate"
.II /dev/freemem
.II "driver^read free memory"
.II "device driver^read free memory"
.B /dev/freemem
is the device from which you can read the system's free memory at any given
moment.
It has major device 0, the same as
.B /dev/null
and
.BR /dev/cmos ;
and minor number 12.
.PP
This non-portable device node is used exclusively for tracking the amount of
free memory in the system.
Its driver recognizes the system calls
.BR open() ,
.BR close() ,
.BR read() ,
and
.BR ioctl() ,
but not
.BR write() .
.SH Example
The following program prints the amount of free memory in your system.
.DM
#include <fcntl.h>
#include <sys/null.h>
#include <stdlib.h>
.DE
.DM
main()
{
	FREEMEM freemem;
	int fm_fd;
.DE
.DM
	fm_fd = open("/dev/freemem", O_RDONLY);
.DE
.DM
	if (fm_fd >= 0) {
		ioctl (fm_fd, NLFREE, &freemem);
		close (fm_fd);
		printf ("Available memory: %d kilobytes\en", freemem.avail_mem);
		printf ("Free memory: %d kilobytes\en", freemem.free_mem);
	} else
		printf("Cannot open /dev/freemem\en");
}
.DE
.SH "See Also"
.Xr "device drivers," device_dr
.Xr "hmon," hmon
.Xr "ioctl()," ioctl
.Xr "null" null
