A stack seems to always be smaller than a free store.
On the systems I use regularly (Solaris on Sparc and Linux on a
PC), the stack and the free store compete for the same memory,
with the first to ask for it getting it. (Once allocated for
one, the memory can never be used for the other.)
By default, an artificial limit is imposed by the OS on the
stack size, so that a program with endless recursion will
terminate in my lifetime. The user can normally specify this
limit (8 Meg by default on my Sparc), however, or specify that
he doesn't want it at all.
Of course, if the stack becomes so big that you start paging on
every function call, it's going to slow things down a bit
.
(Function calls don't actually require any memory accesses on a
Sparc, but it would be a rare function that didn't actually make
some accesses somewhere, at least if the code isn't optimized.)
There are usually ways when compiling a program to increase
the stack size (see your compiler documentation) but 68MB is
probably pushing it.
One, you don't have to recompile, just modify the runtime
environment, and two, on a modern machine (at least on a PC or a
Sparc), there's absolutely no problem with 68MB on the stack if
you've got enough memory. (On one of the Linux machines here,
with a fair amount of memory, I was able to recurse 30 times
with a data structure of 68 Meg on the stack. On my Sparc, with
a lot less real memory, I interrupted the process after 16
recursions, because the disk thrashing was interfering with
other more important processes.)
As Victor said, you should probably move the allocation of the
memory to the freestore, which generally has a much larger
limit. Use new and some sort of smart pointer (I personally
would use a naked pointer, but that is generally frouwned
upon).
It depends on where and what. If he's only allocating a single
instance, either a static variable or an automatic variable in
main would do the job just as well. (I'd go for the static
instance, since this would mean that the program could run in
the default environment, without the user having to invoke
ulimit first.) If he needs several, at least under Solaris, it
really doesn't matter whether he uses dynamic allocation or auto
variables, as far as memory goes. I'd go with dynamic
allocation, however, because it allows error checking---you're
informed if the allocation fails, rather than just core dumping.
Check your compiler documentation for increasing the size of
the stack. That documentation should state the default size
of the stack and how large it can be increased to with some
compiler switch.
"man ulimit" should be sufficient.