# The cost of loading an unneeded module



## Bill Evans at Mariposa (Nov 3, 2015)

If, to keep my scripts simple, I load a module that I might not use, and I end up not using it until I reboot the machine later, what has the unnecessary module loading cost me?  I'm thinking of the linux module, but I don't that that's relevant.


----------



## uzsolt (Nov 3, 2015)

Maybe kldstat(8)?


----------



## usdmatt (Nov 3, 2015)

I'm no authority but I suspect the answer to this is very little. If it's not doing anything, it's not going to be using any cpu/disk/etc resources. Pretty much I think it will just be the memory used by the module, which will likely be next to nothing. As mentioned `kldstat` will show the size of the module. Man page doesn't seem to specify what units the size are but I'd hazard a guess at bytes in hex. On my system even the entire generic kernel shows a whopping 23MB, which seems about right when compared to the kernel file itself - /boot/kernel/kernel.


----------



## kpa (Nov 3, 2015)

The cost should be negligible unless the modules include drivers that actually attach to a device or install handlers that get constantly run by the system.


----------



## Bill Evans at Mariposa (Nov 3, 2015)

usdmatt said:


> Man page doesn't seem to specify what units the size are but I'd hazard a guess at bytes in hex.


Seeing as the size for the linux module is listed as 43c7c, that has to be hex. And it's probably in bytes; translated to decimal, it's 277628, and the size of linux.ko is 692872. (All this is for 10.2-RELEASE).


----------

