[metadata]
id = "MEM11-C"
type = "recommendation"
category = "MEM"
number = 11
title = "Do not assume infinite heap space"
description = """
Memory is a limited resource and can be exhausted. Available memory is typically
bounded by the sum of the amount of physical memory and the swap space allocated
to the operating system by the administrator. For example, a system with 1GB of
physical memory configured with 2GB of swap space may be able to allocate, at
most, 3GB of heap space total to all running processes (minus the size of the
operating system itself and the text and data segments of all running
processes). Once all virtual memory has been allocated, requests for more memory
will fail. As discussed inERR33-C. Detect and handle standard library errors,
programs that fail to check for and properly handle memory allocation failures
will haveundefined behaviorand are likely to crash when heap space is exhausted.
Heap exhaustion can result from Ifmalloc()is unable to return the requested
memory, it returnsNULLinstead. However, simply checking for and handling memory
allocation failures may not be sufficient. Programs such as long-servers that
manipulate large data sets need to be designed in a way that permits them to
deliver their services when system resources, including the heap, are in short
supply. Making use of additional storage devices, such as disk space or
databases, is essential in such systems.
"""
severity = "Low"
likelihood = "Probable"
priority = "P2"
level = "L3"
cert_version = "2016 Edition (Wiki)"
last_modified = "Unknown"
[rules.cert_c.MEM11-C]
enabled = true
[references]
wiki = "https://wiki.sei.cmu.edu/confluence/display/c/MEM11-C.+Do+not+assume+infinite+heap+space"
cwe = ["CWE-770"]