Hi, Le Thu, 17 Aug 2006 12:29:15 +0530, "Abu M. Muttalib" <abum@xxxxxxxxx> a écrit : > In an application I am freeing some memory address, earlier reserved > with malloc. > > I have put prints in remove_vm_struct() function in ./mm/mmap.c. For > few calls to free(), there is no corresponding call to > remove_vm_struct(). I am not able to understand why the user space > call to free() is not propagated to kernel, where in the > remove_vm_strcut() function should get called. Unfortunately, things are not so simple. There's no direct mapping between malloc()/free() allocations and creation/destruction of VMAs. malloc(), implemented in C library, manages a pool of memory so that your applications can allocate and free memory. When it needs more memory from the kernel, it has two options: either grow the heap using the brk() system call, or by mapping another anonymous region using mmap(). The choice between these two options depends on malloc() internals. When calling free(), the C library allocator will not immediatly free the memory in the kernel: either because some parts of the page are still used, or maybe because it prefers to keep some unused memory in order to not be forced to ask the kernel for memory again at the next malloc() call. Don't hesitate to ask for details, because my explanation is probably not 100% clear. Sincerly, Thomas -- Thomas Petazzoni - thomas.petazzoni@xxxxxxxx http://{thomas,sos,kos}.enix.org - http://www.toulibre.org http://www.{livret,agenda}dulibre.org -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/