Page 1 of 1

Memory problem/question [SOLVED]

Posted: 2008-04-22T15:08:51-07:00
by efo
Hi all,

I was wondering if someone could give me some advice on the segmentation fault I get from this piece of code:

int main(void)
{
MagickWandGenesis();
int var[2100000];
}

I think it is a memory problem because I dont get the error if I use "int var[2000000]". Anyway, it looks like 2000000 integer entries shouldnt take up much memory. How can I reduce the memory used by MagickWandGenesis (or better MagickCoreGenesis) and still being able to manipulate average size pictures?

Thank you.

Efo

Re: Memory problem/question

Posted: 2008-04-22T18:57:28-07:00
by magick
You are exceeding the stack limit of your machine/compiler. For images that large, allocate from the heap:
  • int *var;
    var2=(int *) malloc(2100000*sizeof(int));

Re: Memory problem/question

Posted: 2008-04-23T11:19:56-07:00
by efo
Thank you so much magick!!

I realize this was more of a c question, and I really appreciate you taking the time to help me out.

Thanks again.

Efo