1838536 Members
3121 Online
110127 Solutions
New Discussion

Memory

 
Patricia Tang
Advisor

Memory

Hi,

I can only locate 1009 meg malloc'ed When i run malloc program . Currently i have 512 MB Memory and 2 GB Swap space in HP_UX11

Current Kernel Parameter Setting:
maxdsiz :2063835136
maxdsiz_64bit :2063835136
maxfiles :1024
maxfiles_lim :2048
maxssiz :16384000
maxssiz_64bit :20971520
maxswapchunks : 4096
maxtsiz :1073741824
maxtsiz_64bit :2147483648
shmmax :2147483648

I wonder why i can't locate more than 1 GB when i run malloc program?

My malloc program:
main () {
char *mem[250000]; /* one MB here */
int i, j;
for (i = 2; mem[i] = (char *) malloc(1024 *1024); i++)
printf("%d meg malloc'ed\n",i);
}

Please advise.

Many Thanks.

Regards,
Pat
5 REPLIES 5
S.K. Chan
Honored Contributor

Re: Memory

Limitation of malloc can be due to ..
1- kernel parameter (maxdsiz & maxdsiz_64)
2- swap space
I would suggest 2) because it looks like you have increased your kernel parameters. What you can do is quickly create filesystem swap on-the-fly and run your malloc program again to see if you still have the error. If swap space is the cause, you would then add device swap later.
steven Burgess_2
Honored Contributor

Re: Memory

try this instead

#script to check installed and freememory

#/usr/bin/sh

let x=$(grep -i physical: /var/adm/syslog/syslog.log | head -1 | awk '{print $7
let z=$(vmstat|tail -1|awk '{print $5}')*4096;let z=$z/1000000
let free=100000/$x*$z
let free=$free/1000
let free=100-$free
echo "$x Mb physical memory \n$z Mb memory free \n$free % used"

The above was picked up from one of our more experienced members
take your time and think things through
Patricia Tang
Advisor

Re: Memory

I did monitor ( by using swapinfo -tm ) and confirm that it is 2 GB free swap space.why my malloc program can only run up to 1 GB .

For HP_UX 11 , is there any limitation ?
Do i need to apply patch or is there any kernel parameter need to be set?

Please advise.

Thanks.
S.K. Chan
Honored Contributor

Re: Memory

In that case it's your kernel parameters. Right now you got ..
maxdsiz :2063835136
maxdsiz_64bit :2063835136
maxssiz :16384000
maxssiz_64bit :20971520
I would try to increase maxssiz and maxssiz_64bit first. And then if it still not working, increase maxdsiz and mazdsiz_64bit.


Bill Hassell
Honored Contributor

Re: Memory

Actually, there's another limit. A 32 bit program's data area starts in quadrant 2, giving a maximum of about 960 megs. This is a limitation of a standard 32 bit program.

However, you can change the executable to EXEC_MAGIC and start the data area in quadrant 1 just after the end of the text portion of the program. This gives the program access up to 1900 megs of RAM. To create an executable in EXEC_MAGIC format, link the executable with the -N option. (See ld(1) man page for details.)

Read all the details in the white paper on memory management in /usr/share/doc.


Bill Hassell, sysadmin