fatimao
asked on
maximum limit of array size
what is the maximum limit of array size ?
e.g. array[n] ... wats the size of n?
i guess it should also depend on the type of array?
kindly clearify the concept
regards
e.g. array[n] ... wats the size of n?
i guess it should also depend on the type of array?
kindly clearify the concept
regards
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
please can you tell what will be the limit of the stack size assigned to the process?
The stack is a part of the process memory used for statically allocated memory (for function calls, local variables, etc.). Its size is entirely implementation/platform dependent and is not prescribed by the C++ standard.
In any case, you shouldn't depend on any value for that size - that's not a safe way to code. If you get to the limit of the stack, your program will generate a stack overflow.
As I said : if you have a lot of memory to allocate, DON'T do it on the stack, but on the heap (ie. dynamically allocated).
Do you know what a stack and heap are, and how process memory is organised ?
In any case, you shouldn't depend on any value for that size - that's not a safe way to code. If you get to the limit of the stack, your program will generate a stack overflow.
As I said : if you have a lot of memory to allocate, DON'T do it on the stack, but on the heap (ie. dynamically allocated).
Do you know what a stack and heap are, and how process memory is organised ?
The C++ language itself does not impose a limit afaik.
Apart from the machine limit of course : the size of an unsigned int - ie. the theoretical limit on a 32-bit machine would be 2^32 - 1. But you'd probably never get there anyway, because you'll hit memory constraints long before that :)
In any case, it's not good practice to create large static arrays (on the stack) - use dynamically allocated memory instead (on the heap).