memory fault, core dump

When we try to allocate memory with malloc for an array of data points, we
always get “memory fault, core dumped”, here is part of our code:


a=(int)(ref_time1000);
output_array=malloc(a
sizeof(double));
if(output_array==NULL)
{
break;
}

What does “memory fault, core dumped” mean?

malloc always takes the value of : 134544568, even if “a” is only 1000.
why does malloc take that value automatically? Is there a way to set the max
value of malloc?

thanx

Can you show us the declarations of ‘a’ and ‘output_array’? What do you
mean ‘malloc takes the value of’? Do you mean that it returns that value?
This is normal because malloc will return a pointer to memory.

cheers,

Kris
“Jun” <nustzhujun@hotmail.com> wrote in message
news:a7o3gt$qin$1@inn.qnx.com

When we try to allocate memory with malloc for an array of data points, we
always get “memory fault, core dumped”, here is part of our code:


a=(int)(ref_time1000);
output_array=malloc(a
sizeof(double));
if(output_array==NULL)
{
break;
}

What does “memory fault, core dumped” mean?

malloc always takes the value of : 134544568, even if “a” is only 1000.
why does malloc take that value automatically? Is there a way to set the
max
value of malloc?

thanx

Jun <nustzhujun@hotmail.com> wrote:

When we try to allocate memory with malloc for an array of data points, we
always get “memory fault, core dumped”, here is part of our code:



a=(int)(ref_time1000);
output_array=malloc(a
sizeof(double));
if(output_array==NULL)
{
break;
}

What does “memory fault, core dumped” mean?

It means, generally that you tried to reference memory that wasn’t
mapped into your process, and that a debug output file for your program
that can be loaded into a debugger (gdb) has been generated.

Bad memory access usually means you derefernced a bad pointer.

malloc always takes the value of : 134544568, even if “a” is only 1000.
why does malloc take that value automatically? Is there a way to set the max
value of malloc?

What do you mean “malloc take the value of” – do you mean it returns that
value?

That might, actually, be expected – the available free space in your
program could always be the same.

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.