开发者

Linux kernel memory management?

开发者 https://www.devze.com 2023-02-05 03:37 出处:网络
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 co

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 kmallocs 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消