473,386 Members | 1,962 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

HPX memory calloc error - returns NULL

Hi,
I have a c applicaiton which uses calloc to allocate the storage from
heap.
A page is allocated (4096bytes) and then its used in smal small chunks
on need.

It works fine till some n number of pages are alloacted and used. But
it fails
to allocate a fresh page of 4096 after some m times when the prev.
block gets exhausted and new block needs to be allocated/reserved.

result = (alloc_list *) calloc((size_t) ASIZE, 1));
The result becomes NULL... (ASIZE is 4096)
Ran purify and it gave a MAF (Memory allocation Failure)

Any hints as how to go about this issue ?

I have a hp machine with limit as :-
$::home> limit
cputime 0:0-1
filesize 4194303 kbytes
datasize 2883584 kbytes
stacksize 262144 kbytes
coredumpsize 0 kbytes
memoryuse 4194303 kbytes
descriptors 200

Regards, ~Pervinder
Nov 14 '05 #1
7 2284
pervinder <pe*******@gmail.com> wrote:
I have a c applicaiton which uses calloc to allocate the storage from
heap.
A page is allocated (4096bytes) and then its used in smal small chunks
on need. It works fine till some n number of pages are alloacted and used. But
it fails
to allocate a fresh page of 4096 after some m times when the prev.
block gets exhausted and new block needs to be allocated/reserved. result = (alloc_list *) calloc((size_t) ASIZE, 1));
Casting the return value of (c|m|re)alloc() is superfluous and
only will keep the compiler from complaining if you forgot to
include <stdlib.h>.
The result becomes NULL... (ASIZE is 4096)
calloc() (or malloc() or realloc()) returning NULL is completely
legitimate - it means the system can't or won't give you anymore
memory. Why it won't give you more depends on lots of system
specific stuff - you may have reached some system-imposed limits,
limits set for your processes, or you may already be using up all
memory there is etc. - so you will have to ask in a group dedicated
to your system or perhaps comp.unix.programmer.
I have a hp machine with limit as :-
$::home> limit
cputime 0:0-1
filesize 4194303 kbytes
datasize 2883584 kbytes
stacksize 262144 kbytes
coredumpsize 0 kbytes
memoryuse 4194303 kbytes
descriptors 200


But even there your printout of the limits will be useless unless
you also tell after how many allocations it fails - if 'datasize'
stands for the upper limit of memory your program is allowed to
use it wouldn't be a surprise if calloc() fails after about 720,000
allocations, but things would probably be different if it fails
after only say 5 (assuming that you really have several GB of
(virtual) memory and the above numbers aren't due to an unrea-
sonable setting of the limits).
Regards, Jens
--
\ Jens Thoms Toerring ___ Je***********@physik.fu-berlin.de
\__________________________ http://www.toerring.de
Nov 14 '05 #2
On 13 Dec 2004 13:38:42 GMT, Je***********@physik.fu-berlin.de wrote
in comp.lang.c:
pervinder <pe*******@gmail.com> wrote:
I have a c applicaiton which uses calloc to allocate the storage from
heap.
A page is allocated (4096bytes) and then its used in smal small chunks
on need.

It works fine till some n number of pages are alloacted and used. But
it fails
to allocate a fresh page of 4096 after some m times when the prev.
block gets exhausted and new block needs to be allocated/reserved.

result = (alloc_list *) calloc((size_t) ASIZE, 1));


Casting the return value of (c|m|re)alloc() is superfluous and
only will keep the compiler from complaining if you forgot to
include <stdlib.h>.


....as is casting either of the arguments to size_t. In this
particular case, if there is no prototype in scope, casting ASIZE to
size_t is particularly useless, as the literal 1 will be passed as an
int. And an int cannot possible be a size_t.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Nov 14 '05 #3
The 'n' is large but total memory allocated till the failure
instant using calloc and malloc calls is ~250 Mb and the
peak memory usage reported byt the executable after
failure is 733 Mb

Since the system has enogh memory (maxdsize 3G) so i
think the issue here is not the memory allocation but its
somewhat different. May be some hp system specific
seting are limiting the same..
-Pervinder

Nov 14 '05 #4
The issue looks more of a hpx system imposed limits.
I tried to allocate chunks of 128Kb till program runs out of memory
And when i run the code on hpux, it goes out of memory after
allocating a 767Mb from heap..
-Pervinder

Nov 14 '05 #5
I used chatr and executable worked fine
$ chatr +q3p enable <ExeName>
Please comment...
-Pervinder

Nov 14 '05 #6
pervinder <pe*******@gmail.com> wrote:
I used chatr and executable worked fine
$ chatr +q3p enable <ExeName>
Please comment...


No, not here since that has nothing to do with C - and you're
posting to comp.lang.c and not comp.solving.hp.ux.problems or
whatever. Go to a group where this is on-topic.

Regards, Jens
--
\ Jens Thoms Toerring ___ Je***********@physik.fu-berlin.de
\__________________________ http://www.toerring.de
Nov 14 '05 #7
pervinder wrote:

I used chatr and executable worked fine
$ chatr +q3p enable <ExeName>
Please comment...


Allright. I have no idea what a chatr is, nor the vaguest idea
what, if anything, you are talking about. With the total lack of
context it could be anything. However I highly suspect it is
off-topic here. I suggest you learn how to use newsgroups.

--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!

Nov 14 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: shilpi.harpavat | last post by:
Hi, I am trying to allocate more memory if the following condition is true. IS it free of memory leaks?? if(numLevels >= numAlloc) { char **oldLevels = levels; long *oldOrder = order;...
3
by: Pushker Pradhan | last post by:
This is similar to my post a few days ago, I'm now doing it correctly but somehow I get Segmentation errors: My function gen_matrix allocates memory for x and returns x with some content: void...
11
by: binaya | last post by:
Dear all, Say I allocate a block of memory using the command malloc.I have a question. Can I deallocate certain portion of it only during runtime ? For eg: Say I allocate 5 pointers to int...
72
by: ravi | last post by:
I have a situation where i want to free the memory pointed by a pointer, only if it is not freed already. Is there a way to know whether the memory is freed or not?
7
by: David Jacques | last post by:
I have to reformat a string from the form "SRID=4269;POINT(-90.673 69.4310000006199)" to GeometryFromText('POINT (-141.095 68.5430000006417)',4269) ); I have a function to do this by...
21
by: smartbeginner | last post by:
main() { int i; int *a; a=calloc(4,sizeof(*a)); /* The above code I know will not compile .But why cant I allocate space for all 4 integers i need to store */ for(i=0;i<2;i++)...
17
by: dtschoepe | last post by:
Hi, I have a homework project I am working on, so be forwarned, I'm new to C programming. But anyway, having some trouble with a memory allocation issue related to a char * that is a variable...
9
by: weidongtom | last post by:
Hi, I've written the code that follows, and I use the function add_word(), it seems to work fine *before* increase_arrays() is called that uses realloc() to allocate more memory to words. But...
6
by: Praetorian | last post by:
This is actually 2 questions: The first one: I have a function (FuncA) calling another (FuncB) with a set of parameters which also includes an int * initialized to NULL before the call. Now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.