--- url: "https://owasp.org/www-community/vulnerabilities/Memory_leak" titulek: "Memory leak | OWASP Foundation" h1: "Memory leak" popis: "Memory leak on the main website for The OWASP Foundation. OWASP is a nonprofit foundation that works to improve the security of software." jazyk: "en" kanonicka: "https://community.owasp.org/vulnerabilities/Memory_leak" drobecky: [] zdroj: "live" wayback_snapshot: "" stazeno: "2026-09-14 10:59:49" znaku: 4881 slov: 723 kodovani: "utf-8" sha256: "d84d5551254ccf1e7f33ccb70ffcf41233ce090707e4dd8a93cddad6705a04f3" --- # Memory leak ## Description A memory leak is an unintentional form of memory consumption whereby the developer fails to free an allocated block of memory when no longer needed. The consequences of such an issue depend on the application itself. Consider the following general three cases: | Case | Description of Consequence | | --- | --- | | **Short Lived User-land Application** | Little if any noticable effect. Modern operating system recollects lost memory after program termination. | | **Long Lived User-land Application** | Potentially dangerous. These applications continue to waste memory over time, eventually consuming all RAM resources. Leads to abnormal system behavior. | | **Kernel-land Process** | Very dangerous. Memory leaks in the kernel level lead to serious system stability issues. Kernel memory is very limited compared to user land memory and should be handled cautiously. | Memory is allocated but never freed. Memory leaks have two common and sometimes overlapping causes: - Error conditions and other exceptional circumstances. - Confusion over which part of the program is responsible for freeing the memory Most memory leaks result in general software reliability problems, but if an attacker can intentionally trigger a memory leak, the attacker might be able to launch a denial of service attack (by crashing the program) or take advantage of other unexpected program behavior resulting from a low memory condition [1]. ## Risk Factors - Talk about the [factors](https://owasp.org/www-community/OWASP_Risk_Rating_Methodology) that make this vulnerability likely or unlikely to actually happen - Discuss the technical impact of a successful exploit of this vulnerability - Consider the likely [business impacts] of a successful attack ## Examples ### Example 1 The following example is a basic memory leak in C: ``` #include #include #define LOOPS 10 #define MAXSIZE 256 int main(int argc, char **argv) { int count = 0; char *pointer = NULL; for(count=0; count