Array size limit?

Hello,

I’m sorry to bother you because I’m sure my question has been already
answered somewhere but I just can’t find the answer. So here’s the question:

Is there some kind of a limit in SDL for the amount of memory that can
be allocated? I’m trying to allocate space for double[57000000] (don’t
ask why) but it causes an access violation/segmentation fault. Even
double[270000] seems to be too much. Without SDL I can easily allocate
the memory I need (actually about 453 megabytes of it). I’ve tried
allocating the memory both statically and dynamically.

Thanks in advance.

Anttoni Jaakkola

Is there some kind of a limit in SDL for the amount of memory that can
be allocated? I’m trying to allocate space for double[57000000] (don’t
ask why) but it causes an access violation/segmentation fault. Even
double[270000] seems to be too much. Without SDL I can easily allocate
the memory I need (actually about 453 megabytes of it). I’ve tried
allocating the memory both statically and dynamically.

Hi,

Depending WHERE you allocate this Memory, it will be reserved on the Stack.
Depending on your Environment - Stack is often limited to 8 MB or even
smaller.

Try:
Double *doubleField = malloc( sizeof( double) * 57000000 );
Instead, in order to reserve the Memory on Heap.

There might also be a Problem reserving more Memory than is available on
your System. Check your available RAM within your System tools (top /
Sysmon,…).

Regards

Thomas G?ttling

That wouldn’t a limit of SDL, would it, but rather of the compiler and
the memory model it’s compiling under. Used to be under my old compiler
I couldn’t reserve more than 64K because of the size of the memory
segment. That was primarily for console based programs. Although
Windows allows something like 4 Gig of total space for a program, there
might still be a limitation on any given piece of data.

With what I know today I’d probably be more inclined to use C++ and a
vector class. Even then there still might be some limitations depending
on how the vector class is implemented.

Lilith>>> On 2/12/2007 at 2:54 AM, Anttoni Jaakkola wrote:
Hello,

I’m sorry to bother you because I’m sure my question has been already
answered somewhere but I just can’t find the answer. So here’s the
question:

Is there some kind of a limit in SDL for the amount of memory that can

be allocated? I’m trying to allocate space for double[57000000] (don’t

ask why) but it causes an access violation/segmentation fault. Even
double[270000] seems to be too much. Without SDL I can easily allocate

the memory I need (actually about 453 megabytes of it). I’ve tried
allocating the memory both statically and dynamically.

Thanks in advance.

Anttoni Jaakkola


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org