Operating System - HP-UX
1833151 Members
3353 Online
110051 Solutions
New Discussion

Re: Allocation Memory Problem

 
SOLVED
Go to solution
Filosofo
Regular Advisor

Allocation Memory Problem

Hi,
I have a problem with application memory allocation.
I try to create a simple C program to verify memory allocation trough malloc system calls.
I verify with glance and see that the max allocate memory is 944MB VSS and 15MB RSS for my C process
I execute a tusc command to see the status of C program, and it return the following error:

brk(0x7b106000)....ERR#12 ENOMEM


I verify the values of kernel parametrs :

shmem 1
shmmax 0X200000000
shmmni 512
shmseg 512
maxdsiz 4294963200
maxdsiz_64bit 6442450944
maxfiles 300
maxfiles_lim 4224
maxqueuetime 0
maxssiz 0X800000
maxssiz_64bit 0X800000
maxswapchunks 2048
maxtsiz 0x4000000
maxtsiz_64bit 0X40000000

In attach the textof C programm.
Are there memory limitation that causes my error ?
Thanks for helps

Bye Filo
Sistem engeneer expert
3 REPLIES 3
Bill Hassell
Honored Contributor
Solution

Re: Allocation Memory Problem

944 megs is the maximum amount of RAM your 32bit program can allocate unless you adjust the compile and executable options. 32bit programs have 4 separate quadrants, each 1Gb in size. So the data area (where malloc starts allocation RAM) is 1Gb and with some overhead items, the limit is about 940megs. Note also that the kernel parameter maxdsiz (which is for 32bit programs) will further limit the maximum size.

Now, by recompiling your program with EXEC_MAGIC options, you can get both quadrant 1 (called 'text area' or the executable instructions) and quadrant 2 (local data area) to be treated as a single local data area, allowing your program to allocate up to about 1750megs. Try recompiling with:

cc -Ae -Wl -N -o myprog myprog.c

You can also modify the EXEC_MAGIC executable with the chatr program to map quadrant 3 and 4 (but VERY dependent on HP-UX version and patches). Or recompile your program as a 64bit program and all RAM limitations disappear (be sure to change maxdsiz_64 to a larger value, perhaps 20-50 Gb. Note that you do not need 30Gb of RAM to run a program that allocates 30Gb of memory -- just make sure you have plenty of swap, such as 40Gb of swap on a system with 4Gb of RAM. Yes, it will run and allocate the memory just fine although a lot of swap reservation will take place.

The attached program will demonstrate the following maximum malloc limits:

940megs
1750megs
2700megs
3700megs
and unlimited with 64bit compile.


Bill Hassell, sysadmin
Filosofo
Regular Advisor

Re: Allocation Memory Problem

Hi Bill,
thanks for Help.
I try to compile my C programm with your optinos:

usr/bin/cc -Ae -Wl -N -o program prova.c

I recived this output:

/usr/ccs/bin/ld: (Warning) At least one PA 2.0 object file (prova.o) was detected. The linked output may not run on a PA 1.x system

Can you re-send the attachment...I can't download it.

Thanks

Bye Filo

Sistem engeneer expert
Bill Hassell
Honored Contributor

Re: Allocation Memory Problem

The attached file displays fine. Rather than selecting download, just open it with Notepad and either copy the text or save the text as a local file on your PC. The warning message is normal. It means that the executable won't run on a very old HP box (ie, PA 1.1). Did the compilation produce as executable file (ie, "program")?


Bill Hassell, sysadmin