Izzo
Izzo

Reputation: 4948

What defines the maximum size of a global array in C?

Let's say I declare a global array in my C program (i.e. it's not allocated in stack memory).

What is the largest array I can create? Is it just a limitation of available memory on the machine? Or is there some other OS setting that typically controls this?

Upvotes: 0

Views: 1104

Answers (1)

Eric Postpischil
Eric Postpischil

Reputation: 224596

There is no single largest bound on an array size in C. In any particular implementation, it may be limited by actually available memory (either main memory or swap space on disk, according to operating system features and settings), policy set by the system operator, capability of the address space, limitations of the compiler, and possibly other factors.

The limit may be available memory in one system and address space in another system.

Upvotes: 3

Related Questions