memory shortage

C

Chang Byun

hello,
I have a trouble when I run a C program.
It have several big pointer variables like 4 by 5000000.
The program is supposed to calculate that big variables with
different parameters repeatedly.
When process run several times, the first serveral runs are fine but
all the memory(main memory and swap memeory) is out of and
it is stop finally.
I am pretty sure that I free every variables for a each run.

My questions are,

1. if the process is needs more memory even though the variables
have been released with free()
2. what is the best way to manage memory
3. is it better to break down a big variables into smaller variables
and run more
4. if there is memory leak, how can I find it?

Any suggestion and helps would be appreciated.

Thanks,

Chang
 
R

Ravi Uday

Chang Byun said:
hello,
I have a trouble when I run a C program.
It have several big pointer variables like 4 by 5000000.

How have you allocated space for these variables. Static allocation not
adviced, if you use dynamic allocaton then make sure you check on the return
value.
The program is supposed to calculate that big variables with
different parameters repeatedly.
When process run several times, the first serveral runs are fine but
all the memory(main memory and swap memeory) is out of and
it is stop finally.

Processes, IPC are not discussed here thats off topic. But pretty sure there
is a leak somewhere !
I am pretty sure that I free every variables for a each run.
Really ..
My questions are,

1. if the process is needs more memory even though the variables
have been released with free()
Use malloc/realloc() and check on the return values
2. what is the best way to manage memory
3. is it better to break down a big variables into smaller variables
and run more

Depends on the need for allocation.
4. if there is memory leak, how can I find it?
Use memory diagnostics tools. Google might be of some help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top