Storage duration
Storage duration is the C property that determines how long an object exists during program execution and how its storage is managed.
Modern C, Third Edition
Storage duration is the lifetime category that determines when a C object is created, exists, and is initialized or destroyed.
- How it is used
- Distinguishes an object's lifetime from identifier visibility when reasoning about local, file-scope, and dynamically allocated storage.
- How deep it goes
- Compares declaration properties and initialization rules, with worked shadowing examples and a storage-class table.
- Examples
- Traces shadowed local and `extern` declarations, then uses allocated rational-number objects to illustrate initialization functions.
- What you can do after
- Diagnose/debug with it by separating name visibility from object lifetime and choosing initialization appropriate to storage duration.
Read how Modern C, Third Edition explains storage duration →
Modern C
Storage duration is the C property that specifies how long an object exists during program execution and how its storage is managed.
- How it is used
- Distinguishes how long an object's storage persists from where its identifier is visible, guiding initialization and dynamic-allocation choices.
- How deep it goes
- Works through shadowing and extern declarations, compares storage categories, and develops initialization rules; defers finer object-lifetime and machine-stack details.
- Examples
- Uses shadowed local variables, an extern declaration that selects a file-scope object, and initialization functions for allocated data.
- What you can do after
- Diagnose/debug with it by separating identifier shadowing from object identity and deciding which objects require explicit initialization.
Related concepts
- public visibilitycontrasts with · Public visibility is an access level that allows a declaration or resource to be accessed beyond its defining scope or boundary, subject to the applicable access rules.
- initializationconfigures · Initialization is the process of establishing initial values or a starting state for a program entity, component, resource, or computation before subsequent operation.
- lifetimeconfigures · A lifetime is the interval during which a program entity exists and remains valid or accessible under the applicable language rules.
- static storageincludes · Static storage duration is the storage duration of an object whose lifetime extends throughout program execution.
- thread storage durationincludes · Thread storage duration is a C object storage duration in which an object’s lifetime is associated with a particular thread of execution.
- allocated storage durationincludes · Allocated storage duration is the C storage duration of dynamically allocated storage, ending when it is deallocated, reallocated, or the program terminates.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

