Memory problem/question [SOLVED]

The MagickWand interface is a new high-level C API interface to ImageMagick core methods. We discourage the use of the core methods and encourage the use of this API instead. Post MagickWand questions, bug reports, and suggestions to this forum.
Post Reply
efo

Memory problem/question [SOLVED]

Post 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
Last edited by efo on 2008-04-23T11:20:31-07:00, edited 1 time in total.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Memory problem/question

Post 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));
efo

Re: Memory problem/question

Post 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
Post Reply