Tools like \'ps\' and \'top\' report various kinds of memory usages, such as the VM size and the Resident Set Size. However, none of those are the \"real\" memory usage:
Use the mincore(2) system call. Quoting the man page:
DESCRIPTION
The mincore() system call determines whether each of the pages in the
region beginning at addr and continuing for len bytes is resident. The
status is returned in the vec array, one character per page. Each
character is either 0 if the page is not resident, or a combination of
the following flags (defined in ):