1824355 Members
4304 Online
109669 Solutions
New Discussion юеВ

Getting ENOMEM in calloc

 
Sup
Advisor

Getting ENOMEM in calloc

Hi,

I have program which manages memory manually by
usilng calloc and free. I am getting following
error,

Allocating 28603 of memory using calloc
Failed: Not enough space
Allocation failed size:28603 errno:12 using calloc

# swapinfo -tma
Mb Mb Mb PCT START/ Mb
TYPE AVAIL USED FREE USED LIMIT RESERVE PRI NAME
dev 1024 7 1017 1% 0 - 1 /dev/vg00/lvol2
localfs 60 0 60 0% 512 0 1 /autosys/paging
reserve - 285 -285
memory 387 250 137 65%
total 1471 542 929 37% - 0 -

maxdsiz:16384

The above program allocates memory at other places and releases when exiting.

Wrote sample program which allocates same 28603 bytes and ran parallel to above program. The sample program working fine.

Any help???



2 REPLIES 2
MANOJ SRIVASTAVA
Honored Contributor

Re: Getting ENOMEM in calloc

Hi Sup

You may like to look at this :


http://supportweb.remedy.com/supportweb/Documentation/PDF/technotes/doc1371.pdf

Essentially you need to change the kernel parameters . I am also attaching a simple memtest program to run to find the maximum memory allocated for the process to use . Just unzip it and run it like

memdetail 700000 and it will tell you whterh the proces can run using 700000 bytes .


Manoj Srivastava
A. Clay Stephenson
Acclaimed Contributor

Re: Getting ENOMEM in calloc

You most likely simply need to increase maxdisiz (or the 64-bit equivalent). Swap could be too small and there is one other thing that can cause malloc, calloc, or realloc problems - especially in the 32-bit world. Your memory may be too fragmented to allow for a very large allocation.
If it ain't broke, I can fix that.