Possible memory leak in the kernel (contigmalloc)

Konstantin Belousov kostikbel at gmail.com
Fri Oct 26 20:12:42 UTC 2018

On Wed, Oct 24, 2018 at 04:27:52PM +0000, Bennett, Ciunas wrote:
> Hello,
> I have encountered an issue with a kernel application that I have
> written, the issue might be caused by a memory leak in the kernel.
> The application allocates and deallocates contiguous memory using
> contigmalloc() and contigfree(). The application will fail after a
> period of time because there is not enough free contiguous memory
> left. There could be an issue with the freeing of memory when using
> the contigfree() function.

It is unlikely that there is an issue with a leak, but I would be not
surprised if your allocation/free pattern would cause fragmentation
on free lists that results in contigmalloc(9) failures after.

Look at the vmstat -z/vmstat -m output to see uma and malloc stats.
More interesting for your case can be the output from
	sysctl vm.phys_free
which provides information about the free queues and order of free pages
on them.

More information about the freebsd-stable mailing list