Deep C Dives: Static Storage
Written by Mike James   
Tuesday, 20 May 2025
Article Index
Deep C Dives: Static Storage
Global Variables
Static v Heap

Static v Heap

If you know about heap storage, see Dive 12, then you might be thinking that as static is easier to use than heap storage, why not use it in preference. The advantage of static storage is that no pointers are involved in its creation or management. Its disadvantage is that it isn’t possible to manage it at all. Heap storage can be freed and resized whereas static storage is fixed.

Using static storage can also add to the size of the program file. Static storage and file-level storage is most easily implemented by being compiled into the program and how efficiently this is encoded in the source file varies, but it is possible that if you declare a 1MByte static array the size of your executable increases by 1MByte. This also increases the time it takes to load your program.

 

Deep C Dives
Adventures in C

By Mike James

Cdive360

Buy from Amazon.

Contents

Preface
Prolog C
Dive

  1. All You Need Are Bits
  2. These aren’t the types you’re looking for
  3. Type Casting
  4. Expressions
  5. Bits and More Bits
        Extract:
    Bits!
  6. The Brilliant But Evil for 
  7. Into the Void 
  8. Blocks, Stacks and Locals
  9. Static Storage
  10. Pointers
  11. The Array and Pointer Arithmetic
  12. Heap, The Third Memory Allocation
  13. First Class Functions
        Extract:
    First Class Functions
  14. Structs and Objects
        ExtractValue Structs ***NEW!
  15. The Union
  16. Undefined Behavior
  17. Exceptions and the Long Jump

<ASIN:B0D6LZZQ8R>

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.

Banner


System Initiative Releases AI Infrastructure Automation Platform
01/09/2025

System Initiative has released an AI-native infrastructure automation platform. The company says the platform means engineering teams can work directly with AI agents that not only understand every de [ ... ]



GitHub Adds Copilot Agents Panel
28/08/2025

GitHub has added an agents panel that developers can use to delegate tasks to Copilot from any page on github with a simple prompt. 


More News

pico book

 

Comments




or email your comment to: comments@i-programmer.info



Last Updated ( Tuesday, 20 May 2025 )