brk() isn't the only way applications get memory. A
commonly used method of getting process memory is to mmap()
anonymous regions. Some implementations of malloc() will
use mmap() for larger allocations. If you use realloc() a
lot this can be particularly useful.
Releasing memory that has been allocated via brk() is
dependent on allocation order so it is seldom done.
Realloc() and co. used poorly can produce lots of
fragmentation exacerbating things. Allocations done via
mmap() tend to be independent of one another so they can
released more readily.
If an application or library is using mmap() just watching
brk won't do much good. Actually detecting leakage is very
difficult especially from outside the code. It requires
tracking the modifications of all the pointers to allocated
memory.
The thing to keep in mind for the common case is that
applications that leak memory will release it on exit.
Most of the time any sizable amount of application memory is
in disuse it will be in sizable chunks so under memory
pressure will be paged out until exit so will have minimal
impact on the system.
Having said all that i'll now echo Linus et al and tell you
that you want the system to use all of your memory. Unused
memory is wasted memory and wasted money. That is why
otherwise free memory is used as cache and disused memory
will be paged out so that it too can be used as cache to
speed up the system as a whole.
And much thanks to all the good, and heartless bastard,
developers who have and continue to work on improving the
paging algorithms and VM system as a whole.
-- ________________________________________________________________ J.W. Schultz Pegasystems Technologies email address: jw@pegasys.wsRemember Cernan and Schmitt - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/