memory shortage

Discussion in 'C Programming' started by Chang Byun, Oct 14, 2003.

  1. Chang Byun

    Chang Byun Guest

    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
    Chang Byun, Oct 14, 2003
    #1
    1. Advertising

  2. Chang Byun

    Ravi Uday Guest

    Chang Byun <> wrote in message news:<bmffvm$10fa$>...
    > 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.

    > Any suggestion and helps would be appreciated.
    >
    > Thanks,
    >
    > Chang
    Ravi Uday, Oct 14, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mahesh Prasad
    Replies:
    1
    Views:
    706
    Tom Wells
    Feb 22, 2004
  2. Cy Huckaba
    Replies:
    1
    Views:
    1,148
    Xie Xiao
    Jun 26, 2003
  3. eglato
    Replies:
    117
    Views:
    2,331
    Tris Orendorff
    Jun 24, 2005
  4. Chang Byun

    question about memory shortage

    Chang Byun, Oct 14, 2003, in forum: C Programming
    Replies:
    0
    Views:
    323
    Chang Byun
    Oct 14, 2003
  5. Chang Byun

    question about memory shortage

    Chang Byun, Oct 14, 2003, in forum: C Programming
    Replies:
    4
    Views:
    427
    Chang Byun
    Oct 14, 2003
Loading...

Share This Page