System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

memory allocation for programs

SOLVED
Go to solution
Tom Wallin_1
Advisor

memory allocation for programs

I am wondering how the loader part of an executable calculates the
amount of memory to set aside for each program a user runs in his
environment. That is when a user types in a programs name at the prompt
and hits "Enter" How does the loader figure out how much memory to set
aside for it to run. I think it needs some for code, some for stack
space, and some for data.

We have identical programs, running on different servers, that are
grabbing two different amounts of memory when they are run.
The two different servers are as follows -
1. Alpha 4100 running V4.0F PK7 - has 3GB RAM
2. Alpha ES40 running V5.1b PK4 - has 8GB RAM

On the ES40 the program grabs 10x the amount of memory that it does on
the 4100.

Tom Wallin
15 REPLIES
Hein van den Heuvel
Honored Contributor

Re: memory allocation for programs

What do you use to tell the size?
ps -o RSS,VSZ ?

RSS is Real memory (resident set)
VSZ is Process virtual address size ... the program may or might not touch that all.
I suspect that RSS is similar, VSZ different.

I would also compare output for sysconfig -q proc

And check: ulimit -a


Hope this help some,
Hein.



Ravi_8
Honored Contributor

Re: memory allocation for programs

Hi

can you post output of "ulimit -a" on both machines
never give up
Michael Schulte zur Sur
Honored Contributor

Re: memory allocation for programs

Hi,

the two machines have a substantial difference in built in memory. There is a parameter that tells tru unix how much of a programme to hold in memory. With almost three times the memory size the es40 can hold more in memory.

greetings,

Michael
Tom Wallin_1
Advisor

Re: memory allocation for programs

We are using RSS to compare. Attached is a text file(MS) with the ulimit -a from both machines.

Regards,

Tom Wallin
Hein van den Heuvel
Honored Contributor

Re: memory allocation for programs


Your STACK size seems unreasonable:

ES40 ulimit -a
:
stack(kbytes) 4,194,304

That's 4 GB of stack, where you used 2MB before. The app worked with the 2MB right? So it shoudl still work with that.
4GB of stack is a whole bunch of pagetable pages also!
If you do not have a very good reason for to have set it that high, then just fix the sysconfig proc entry for the stack and be happy.

Hein.


Tom Wallin_1
Advisor

Re: memory allocation for programs

We decided yesterday to do as you suggested. But we are going to adjust the data setting also. Why did you focus in on the stack only? Also does the loader use these values to calculate how much memory to set aside when loaded into memory?

Tom Wallin
Hein van den Heuvel
Honored Contributor

Re: memory allocation for programs

>> Why did you focus in on the stack only?

a) Because I am in a BEA training with limited downtime :-).

b) Because that value is so clearly wrong (assuming you had a working system).
Typical sizes are 32M or so. If you need more (lots of local variables) then you wouls probably know.

c) I could imagine stack being different, as pages on either end will actually be touched.
'data' is just a fence. Just telling the system how far it can go, but you probably will not go there, so it does not matter if it is too far. However... if an application loses control, then it will not be stopped by this clean fence, but by some nasty resource depletion which my hurt other applications.

>> also does the loader use these values to calculate how much memory to set aside when loaded into memory.

Yes... but that is all 'virtual'. Just address ranges.

Tom Wallin_1
Advisor

Re: memory allocation for programs

We changed the setting - per_proc_stack_size and restarted the server and started one of the programs and it was the same saize as before the change. We recompiled the program and restarted it no change.

The ulimit list of stack size did not change either.

What kernel variable should I be changing?

Tom Wallin

ps Thanks for your time.
Michael Schulte zur Sur
Honored Contributor

Re: memory allocation for programs

Tom,

could you post the output of the ps as Hein first suggested from both machines?

thanks,

Michael
Tom Wallin_1
Advisor

Re: memory allocation for programs

Michael,
I tried the ps -o but the ps cmd did not like the RSS or VSZ. It gives the msg - "ps: unknown variable in format: RSS".

I was wrong about the stack size not changing in my previous msg. The size did change.

Hein van den Heuvel
Honored Contributor

Re: memory allocation for programs

Oh, RSS could be the column header for display purposes, and rss the option field.
Just use 'man ps' and '/RSS'

Hein.
Michael Schulte zur Sur
Honored Contributor
Solution

Re: memory allocation for programs

Hi,

try this:
ps -eo pid,rssize,vsize,command

greetings,

Michael
Tom Wallin_1
Advisor

Re: memory allocation for programs

I got the ps -O thing now. Attached is the ps cmd from each server as a MS text file.

Tom Wallin
Tom Wallin_1
Advisor

Re: memory allocation for programs

I have tried tha things suggested. We are still stuck with the same problem. I have moved the question to the "General" part of the forum.

Tom Wallin
Tom Wallin_1
Advisor

Re: memory allocation for programs

I wanted to update this thread with the final fixes. Both were settings in sysconfigtab. One in the vm: section - vm_segmentation and one in the rt: section aio_task_max_num.
We started with a program that was taking 10MB of RSS per user. It turns out that the program itself takes 1.8MB of RSS. Another 3.6MB was taken when vm_segmentation was set to 1. This setting causes all libraries referenced by the program to be loaded with it into memory. This was for security purposes.
And the last amount of RSS 4.6MB was taken because we had the aio_task_max_num set to 60108. This setting causes the initialization routines in libaio to allocate 60108 aio result blocks. These are used to contain context for outstanding aio requests. At 80 bytes per result block the resulting memory allocation is 587 pages (4.6 Mbytes).
We think that the 60108 was set for Database purposes. But we are unsure why. We did not need the setting for Informix.

Tom Wallin