Electric Fence
Electric Fence is a memory debugger written by Bruce Perens. It consists of a library which programmers can link into their code to override the C standard library memory management functions. eFence triggers a program crash when the memory error occurs, so a debugger can be used to inspect the code that caused the error.
Electric Fence is intended to find two common types of programming bugs:
- Overrunning the end of a dynamically allocated buffer
- Using a dynamically allocated buffer after returning it to the heap
Electric Fence allocates at least two pages for every allocated buffer. In some modes of operation, it does not deallocate freed buffers. Thus, Electric Fence vastly increases the memory requirements of programs being debugged. This leads to the recommendation that programmers should apply Electric Fence to smaller programs when possible, and should never leave Electric Fence linked against production code.
Electric Fence is free software licensed under the GNU General Public License.