Re: calloc fails and returns NULL

Discussion in 'C Programming' started by Ben Bacarisse, Nov 7, 2012.

  1. k2ibegining <> writes:

    > in one of our application's module, calloc() is failing and returning
    > NULL. The amount of memory that it is trying to allocate is of
    > structure which is of 9292 bytes. The operating system is AIX 7.1 and
    > running VIOS 2.2.1.3.
    >
    > The machine has 2+GB ram and does not seems to have an issue with lack
    > of memory. The same application module is running fine on one of the
    > other boxes, which has same configurations as the problematic
    > box.Following is a snippet of memory from both the boxes and they are
    > same !


    There's nothing peculiar in what you are reporting, unless there's a lot
    you haven't said. Is it a well-controlled test case that fails on one
    system and not on anther? You report the resource limits set on both
    machines but not the available resources at the time the test is done,
    so there's no information to suggest the two machines are in the same
    state when one fails and the other does not.

    The point is that what looks surprising to you won't look surprising to
    your readers, and that's going to affect how many useful answers you
    get. For example, this answer is not going to be much use (it's a
    meta-answer more than anything else). My first reaction was "oh, could
    be almost anything" and I was not going to post at all.

    Because of the way C works, allocation failures are often a symptom of
    some earlier error and don't, in fact, have anything to do with
    available memory. Since this is a C group, code is crucial. If it does
    turn out to be a C problem, it can only be diagnosed by seeing the code!

    So, is it a controlled test case? What is the memory usage at the time
    of the failure? What does the code look like? Can you run it under a
    memory checker like valgrind or electric fence? How do you know what's
    happening (is it a logged error, a message from a debugger, etc)?

    <snip>
    --
    Ben.
     
    Ben Bacarisse, Nov 7, 2012
    #1
    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. Philip Lantz

    Re: calloc fails and returns NULL

    Philip Lantz, Nov 7, 2012, in forum: C Programming
    Replies:
    0
    Views:
    219
    Philip Lantz
    Nov 7, 2012
  2. Greg Martin

    Re: calloc fails and returns NULL

    Greg Martin, Nov 7, 2012, in forum: C Programming
    Replies:
    0
    Views:
    208
    Greg Martin
    Nov 7, 2012
  3. Keith Thompson

    Re: calloc fails and returns NULL

    Keith Thompson, Nov 7, 2012, in forum: C Programming
    Replies:
    0
    Views:
    240
    Keith Thompson
    Nov 7, 2012
  4. Anand Hariharan

    Re: calloc fails and returns NULL

    Anand Hariharan, Nov 7, 2012, in forum: C Programming
    Replies:
    0
    Views:
    206
    Anand Hariharan
    Nov 7, 2012
  5. Ian Collins

    Re: calloc fails and returns NULL

    Ian Collins, Nov 8, 2012, in forum: C Programming
    Replies:
    0
    Views:
    267
    Ian Collins
    Nov 8, 2012
Loading...

Share This Page