Apple Interview Question
Software Engineer / DevelopersCountry: United States
1.
Log all allocation addresses and remove an address entry on a free. If there is a leak, then there will be a lot of allocation messages and no corresponding frees. NOTE: assumption is that freed address has to be same as allocated address. If we allocate two structures together and free them separately, then we need some more work.
2.
If a slab allocator kind of model is used, then we can see if a particular slab is allocating a lot of memory.
Refer to article "Detecting kernel memory leaks" [LWN.net]
- geekgeekmoregeek September 07, 2012it may help