I have written a long program with c, and am using dynamic memory allocation. This program is supposed to be run over and over (300 times) for a long simulation. But the program stops after 120 cycles due to memory leackage. I am not very expert in programing but it seems that my free() function does not do anything to my program. One example of how I do memory allocation and free is this:
int *D;
D= (int *) malloc(size).
void myfunction{
I use D here;
free(D);
...
}
void main()
{
...
myfunction();
}
When I disable "free();" there is no difference in memory consumption, and it stops at cycle 120 again. Is there anything wrong with the way I allocate memory to D or free it.
Thanks and looking forward to hearing from you soon.
Farshid
int *D;
D= (int *) malloc(size).
void myfunction{
I use D here;
free(D);
...
}
void main()
{
...
myfunction();
}
When I disable "free();" there is no difference in memory consumption, and it stops at cycle 120 again. Is there anything wrong with the way I allocate memory to D or free it.
Thanks and looking forward to hearing from you soon.
Farshid
Comment