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 ***NEW!
  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
  15. The Union
  16. Undefined Behavior
  17. Exceptions and the Long Jump

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


Python Parallel? Not Quite Python 14
23/07/2025

Python is a wonderful language, but lack of speed is its main drawback. Can the Python community create a fully threaded Python to be proud of? It's a big challenge.



TIOBE - Two To Rule Them All
16/07/2025

The July Tiobe index is out and it isn't particularly interesting until you notice that it confirms the standard model of programming -  code is written in Python and C and everything else is jus [ ... ]


More News

pico book

 

Comments




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



Last Updated ( Tuesday, 20 May 2025 )