Velocity Reviews

Velocity Reviews (
-   C Programming (
-   -   Re: calloc fails and returns NULL (

Ben Bacarisse 11-07-2012 12:32 PM

Re: calloc fails and returns NULL
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
> 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)?


All times are GMT. The time now is 02:37 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.