Thanks to all for their resonse!

Ok, just one thing -
When I do lsmod -
it shows the memory used by loaded LKMs. So if there is a leak in LKM1 then
after executing the function (which is doing kmalloc but forgetting to do
kfree) of LKM1, lsmod should report an increased memory usage by LKM1. Am I
right?

Thanks


On 1/23/08, Bernd Petrovitsch <[EMAIL PROTECTED]> wrote:
>
> On Mit, 2008-01-23 at 18:31 +0530, Manish Katiyar wrote:
> [...]
> > So If i do a kzalloc() in my module and then unload my module without
> > freeing it, it will be a memory leak...........Am i right ?? .. Or the
>
> Yes.
>
> > kernel is intelligent enough to check and free those memory buffers
> > during unload of the module ?
>
> No.
> That is actually a not-trivial problem[0] as you want to kfree() a
> buffer when the last pointer to it vanishes. And there is no way (except
> explicit coding it that way) to e.g. have automatic reference-counting
> like the typical scripting language (perl, php, ...) or Java.
> For a kernel, there a lots of places where reference counting is just a
> waste of memory and CPU power so no one needs/want's it there.
>
> Next point is: Module unloading happens quite seldom in real life. So it
> makes no sense to invest signifikant amount of work just for that one
> operation (and there are voice who propose to never unload a module in
> real life).
> Next: Module unloading is not the only source of memory leaks. So you
> have to make sure anyways that your module doesn't loose memory.
> Typical error is to allocate memory in an open() sys-call-handler and
> forget to free it on a close() handler.
>
>        Bernd
>
> [0]: Google for "garbage collection".
> --
> Firmix Software GmbH                   http://www.firmix.at/
> mobil: +43 664 4416156                 fax: +43 1 7890849-55
>          Embedded Linux Development and Services
>
>
>
> --
> To unsubscribe from this list: send an email with
> "unsubscribe kernelnewbies" to [EMAIL PROTECTED]
> Please read the FAQ at http://kernelnewbies.org/FAQ
>
>

Reply via email to