Operating System - HP-UX
1832597 Members
3135 Online
110043 Solutions
New Discussion

Re: Apportion of memory for a process By HP-UX

 
SOLVED
Go to solution
Prathima
Occasional Advisor

Apportion of memory for a process By HP-UX

One of the C programs is failing while it tries to allocate 14.3 mb of space using malloc in production. It is compiled as a 32-bit program and has the third quadrant enabled on it.

The output of glance RSS/VSS = 929.6mb/930.3mb when the program failed.

I have the third quadrant private data enabled, the output of chatr on the binary confirms this

"third quadrant private data space enabled
fourth quadrant private data space disabled
third quadrant global data space disabled"

But am not sure why it failed when it has used only 930mb of 2700 mb.

1. Is the RSS memory also included in the allocated 4 GB of memory for a process? Still it is well within the range
2. I saw a documentation saying that, if the underlying OS is a 32 bit version, then the 3rd quadrant enabling will be ignored. Is it true? I am not sure how to check the bit of my OS. can any one help to determine this?
3. I ran a sample program which allocates memory in chunks of 100 mb. I did this in a while loop enabling the third quadrant. In the test environment, it failed only after allocation of 1.86 gb. RSS/VSS at the time of failure was 516kb/ 1.86gb. I copied the same binary to production box, ensured the third quadrant is still enabled, but it failed for a lower RSS/VSS value ==> 376kb/ 1000mb. Considering this behaviour, I feel though my original binary in prodution is enabled for the third quadrant, it is not using it.
Do I have to check for some option at the OS level?

can some one please advice?

12 REPLIES 12
Christian Tremblay
Trusted Contributor

Re: Apportion of memory for a process By HP-UX

You can check the OS "bitness" with the command: getconf KERNEL_BITS
Hein van den Heuvel
Honored Contributor
Solution

Re: Apportion of memory for a process By HP-UX


- You have to link -N to break through 1Gb that gets you to 1.9Gb. So it seems to me the "third quadrant private data space enabled" is not working on the test box either.

- Check MAXDSIZ with sam or kctune.
- Check for adqaut swap space


there are several earlier discussion on this.
Google: +hpux +q3p +site:itrc.hp.com

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=72276

Or google: +malloc +maxdsiz +2gb +site:itrc.hp.com
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1053415

http://www.gehrytechnologies.com/catia/catia/catia_hpux_large_memory.htm

hth,
Hein van den Heuvel
Don Morris_1
Honored Contributor

Re: Apportion of memory for a process By HP-UX

maxdsiz could be coming into play here, but with the test program on the production box failing at only 376kb, I have to wonder if you've checked for the box simply being out of swap (swapinfo -atm). Address space layout, chatr and the rest don't matter if malloc() can't get swap reservations and returns ENOMEM.
Prathima
Occasional Advisor

Re: Apportion of memory for a process By HP-UX


Thanks for all your responses.
How can I check the maxdsiz?

None of the commands sysdef, kctune, swapinfo works from my login. Do I have to have special preveliges for it?

From Christian's note I could find that My OS is 64 bit.

I did a ulimit -a on my test server and production server. The test server had a higher value for data. Is that the reason why my sample binary worked in test environment and it failed in production?

Test server
-------------
$ ulimit -a
time(seconds) unlimited
file(blocks) unlimited
data(kbytes) 2015464
stack(kbytes) 8192
memory(kbytes) unlimited
coredump(blocks) 4194303

production server
-----------------
time(seconds) unlimited
file(blocks) unlimited
data(kbytes) 1048576
stack(kbytes) 8192
memory(kbytes) unlimited
coredump(blocks) 4194303
Bill Hassell
Honored Contributor

Re: Apportion of memory for a process By HP-UX

The attached program will demonstrate the 5 possible sizes for local (heap) memory: 960 megs, 1800 megs, 2700 megs, 3600 megs (all 32 bit) and depending on your RAM and swap space, dozens of gigabytes when you compile it as a 64 bit program.

You are limited by several factors in getting your program to allocate memory. First is the basic EXEC_MAGIC option to get more than 1 quadrant (1 Gb) using -N. Then you use chatr to change your executable to use +q3p and +q4p to get most the 4 quadrants. If you are running on HP-UX 11.23 or later, ytou can forget all this quadrant stuff and use the MPAS model with -Wl,+as,mpas

However, you cannot use the extra addressing space until your system administrator enables larger program limits. The kernel parameter MAXDSIZ and MAXDSIZ_64 are setup to prevent runaway programs from using all your RAM. The default MAXDSIZ has historically been very low, but since you have gotten up to 900 megs of RAM, MAXDSIZ is at least that large. Check it with:

kmtune | grep maxdsiz

(or kctune if you are on an 11.23 system). NOTE: MAXDSIZ_64 must be greater than MAXDSIZ or MAXDSIZ_64 will become the upper limit. Have your sysadmin change these two parameters to 3700 megs and a much larger value for MAXDSIZ_64.

Your ulimit value for data (memory) follows the MAXDSIZ value. Note that your sysadmin may have limited all users to a lower value in /etc/profile.

Even if you have only 4Gb of RAM but 8 Gb of swap, you can compile this program as a 64bit program and get more than 8Gb of data space.


Bill Hassell, sysadmin
Dennis Handly
Acclaimed Contributor

Re: Apportion of memory for a process By HP-UX

>Hein: You have to link -N to break through 1Gb that gets you to 1.9Gb. So it seems to me the "third quadrant private data space enabled" is not working on the test box either.

This true for IPF but PA should allow you to skip one quadrant and combine 2 & 3.

>Is that the reason why my sample binary worked in test environment and it failed in production?

Yes, that is one reason, your 1GB limit.
Prathima
Occasional Advisor

Re: Apportion of memory for a process By HP-UX

I was finally able to check the maxdsiz value. Below is the output of kmtune command.

maxdsiz 2063835136 - 2063835136
maxdsiz_64bit 0x40000000 - 0X40000000

But my ulimit -a still shows
data(kbytes) 1048576

which should ideally follow maxdsiz value.

Why is it like that?
Prathima
Occasional Advisor

Re: Apportion of memory for a process By HP-UX

Some where I checked that these values are defined in for every user in /etc/user/security file. But I dont see this in my UNIX server.
Prathima
Occasional Advisor

Re: Apportion of memory for a process By HP-UX

I tried to change the data value using

ulimit -d 2015464

but as it is currently set at 1048576. I am unable to do it.

So I have to be the root user to increase beyond what is configured for my login
Bill Hassell
Honored Contributor

Re: Apportion of memory for a process By HP-UX

> maxdsiz 2063835136 - 2063835136
> maxdsiz_64bit 0x40000000 - 0X40000000

maxdsiz=2063835136 = 2Gb
maxdsiz=0X40000000 = 1073741824 = 1Gb

Your system is misconfigured. This is a very common mistake. Tell your system administrator to replace the hex value with decimal numbers like maxdsiz. maxdsiz_64 *MUST* be larger than maxdsiz. If it is less (which it is), then maxdsiz is forced to the maxdsiz_64 value. Change maxdsiz_64 to 4Gb or larger if desired. It is only a fence (a limitation) and does not change anything in your programs.

> But my ulimit -a still shows data(kbytes) 1048576

ulimit defaults to the maxdsiz value which in your system means 1048576 Kb or 1Gb (the value of maxdsiz_64 which is lower than maxdsiz).

> Some where I checked that these values are defined in for every user in /etc/user/security file. But I dont see this in my UNIX server

Not true. All the options for the /etc/default/security file are found in the security man page. ulimit can only be globally set in /etc/profile or you can change the value in your local .profile or from the command line. Read the man page for sh-posix or ksh concerning ulimit.


Bill Hassell, sysadmin
Prathima
Occasional Advisor

Re: Apportion of memory for a process By HP-UX

Thanks to all of you for your responses.

It required to change the maxdsiz parameter as all of you pointed out.
Prathima
Occasional Advisor

Re: Apportion of memory for a process By HP-UX

Thanks for all your responses