Linux kernel memory management?
Wil开发者_StackOverflow社区l Linux Kernel free kmalloc'ed and not kfree'd in kernel module memory after module release just like it's work with user space apps?
The kernel will not do any garbage collection for a module. If the module kmalloc
s a chunk of memory and doesn't kfree
it before the module is unloaded, that chunk will stay allocated and inaccessible until the next reboot.
As others said, the kernel will not do any garbage collection for a module but device drivers can use devm_*
types of resource allocations (called managed resource allocation functions) and the kernel will do all the required cleanups after there is no more reference to the device.
See here for the commented source code in the kernel source for devm_kmalloc.
精彩评论