Messages in this thread | | | Date | Mon, 2 Jun 1997 14:37:44 +0100 (BST) | From | Mark Hemment <> | Subject | Memory Leak Fix |
| |
Hi David/All,
Please find attached a diff against the slab allocator for 2.1.42
This contains the changes for the "Debugging Slab", which was on my homepage, but with the debugging disabled.
Most importantly, it contains a fix for the memory leak.
This occured when a slab contained only one object (ie. the object is _large_). __kmem_cache_free() use to check for a fully free slab, and then for a first-free from a fully active slab (this is to maintain the partial ordering of slabs with a cache).
kmem_cache_full_free() makes the assumption that 'c_freep' refers to the slab being moved, or to a slab which appears earlier in the ordering. Unfortunately, this is not true for single object slabs, as 'c_freep' can refer to a later slab (or even the cache head). If the slab does _not_ need to be moved (to maintain the ordering), it does not update 'c_freep' - which caused the leak.
The fix is to change the testing order in __kmem_cache_free(), so that the test for 'first-object-free' is made before the 'fully-free' test.
Regards,
markhe
---------------------------------------------------- Mark Hemment UNIX/C Sotware Engineer (contractor) "Success has many fathers. Failure is a b**tard" ---------------------------------------------------- [unhandled content-type:application/octet-stream] | |