Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

calloc fails and returns NULL

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 !

WORKING BOX:

RLIMIT_AS      (infinite) (infinite)
RLIMIT_CORE    1073741312 (infinite)
RLIMIT_CPU     (infinite) (infinite)
RLIMIT_DATA     134217728 (infinite)
RLIMIT_FSIZE   (infinite) (infinite)
RLIMIT_NOFILE        2000 (infinite)
RLIMIT_RSS       33554432 (infinite)
RLIMIT_STACK     33554432 2147483646 

PROBLEMATIC BOX:

RLIMIT_AS      (infinite) (infinite)
RLIMIT_CORE    1073741312 (infinite)
RLIMIT_CPU     (infinite) (infinite)
RLIMIT_DATA     134217728 (infinite)
RLIMIT_FSIZE   (infinite) (infinite)
RLIMIT_NOFILE        2000 (infinite)
RLIMIT_RSS       33554432 (infinite)
RLIMIT_STACK     33554432 2147483646 

I'm clueless as can't really figure out why calloc() is failing even for 9292 bytes on this box.

Thanks

like image 850
kuldeep Avatar asked Nov 06 '12 06:11

kuldeep


1 Answers

Try calloc(1, sizeof(ifp_handle_t)); instead of calloc(sizeof(ifp_handle_t), 1); I maybe wrong but it seems you inverted the parameters.

like image 176
Waterfrag Avatar answered Sep 24 '22 14:09

Waterfrag