On Tue, Oct 29, 2013 at 01:22:39AM +0530, Raheel Gupta wrote: > Sir, is there any way to not allow malloc to hold memory ? I mean shouldnt > free(), be freeing the memory ?
No. The way malloc() typically works is that it allocates large chunks of memory from the OS's kernel, then it allocates chunks of the desired size to the callers of malloc(). Over time the heap (the large chunks of memory that malloc() uses for making small allocations) gets fragmented. Once a heap is fragmented it's impossible to return some of those large chunks of memory to the OS kernel, not without a garbage collector that relocates memory, but C doesn't have a standard garbage collector (much less one that rewrites memory!). What SQLite3 could do is use mmap() to allocate its page cache, and then it could munmap() pages when it's done with them. But it doesn't do this. Or SQLite3 could dispense with the page cache and just mmap() the whole file (or windows into it) and let the OS do all the caching. But SQLite3 cannot force the free() to return memory to the OS. Nico -- _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users