malloc() Question

Hi Guys,

I have a quick question. Actually, I developed a program on MAC OS X (Terminal) and it works fine, however when I run that same program on Linux Machine, it breaks saying that memory freed twice and it prints the entire memory map. Now I have double checked my program and made sure that I am not freeing the any memory twice. Any idea why this is happening?

Thanks in advance.
What do you mean by "it prints the entire memory map"? This is not a standard function of the linux kernel or glibc.

If using GCC, do

extern MALLOC_CHECK_=2

and run your program from the shell that you ran the above command in.
it must have dumped the memory on the screen when the program crashed.
Thanks a lot for the reply jsmith and writetonsharma. I fixed the problem. Apparently, on MAC's Terminal when we declare a variable it initializes it to zero, whereas on Linux it does not. There was one variable I was using somewhere which was not initialized and it was one of the problem. There were few others too. But finally everything works. :)
It might happen to have been zero; C++ is not going to initialize a POD type to zero for you.
Topic archived. No new replies allowed.