1753783 Members
6877 Online
108799 Solutions
New Discussion юеВ

malloc() - Error No 12

 
SOLVED
Go to solution
KennethMRay
Advisor

malloc() - Error No 12

Hi all, I am getting an errno 12...basically an error when we run a program and the dsiz hits around 900MB...but our maxdsiz and maxdsiz_64bit are larger and actually are set exactly the same as another box where the program runs fine. I've even bumped up maxdxiz &64bit and ran the program just to see if that was it, but it still dies at the same place.

Any ideas?

Thanks,
12 REPLIES 12
James R. Ferguson
Acclaimed Contributor

Re: malloc() - Error No 12

Hi:

Well, errno = 12 = ENOMEM

If this is a 32-bit process, then 'maxdsiz' sets the limit. If this is a64-bit process, then 'maxdsiz_64bit'

This can also be caused by a lack of swap space. Verify with 'swapinfo -tam'.

Regards!

...JRF...
KennethMRay
Advisor

Re: malloc() - Error No 12

Yeah, we've got plenty of swap and maxdsiz is set the same as another box where it runs fine. Now I just wrote a small c program just to test how far it will go and it bombs at around 889MB but runs further on the other system setup the same.

Now, I just recompiled this small program that I wrote with +dd64 and then when I run it it goes further...but before it dies earlier and the issue is why it only goes to 889MB on this box but much further on the other box that is darn near identical...kernel bits, maxdsiz, dsiz_64bit, tsiz, ssize, swap, etc...
KennethMRay
Advisor

Re: malloc() - Error No 12

Here are the differences in the kernels...nothing that should be causing this difference that I can see.

< dbc_max_pct 3 3 Immed
< dbc_min_pct 2 2 Immed
---
> dbc_max_pct 12 12 Immed
> dbc_min_pct 5 Default Immed
53c53
< maxdsiz 1073741824 1073741824 Immed
---
> maxdsiz 1073741824 Default Immed
59c59
< maxssiz 134217728 134217728 Immed
---
> maxssiz 8388608 Default Immed
62c62
< maxtsiz_64bit 1073741824 1073741824 Immed
---
> maxtsiz_64bit 1073741824 Default Immed
64c64
< maxvgs 256 256
---
> maxvgs 100 100
James R. Ferguson
Acclaimed Contributor

Re: malloc() - Error No 12

Hi (again):

What I'm saying is that a 32-bit applications is goverened by 'maxdsiz' --- not 'maxdsiz_64-bit'. Further, a 32-bit appplication has a data size limit of about 940MB unless it has been enabled with 'chatr' to be an 'EXEC_MAGIC' executable and then the limit is ~ 1.9 GB for the data space.

Do a 'file' on your executable. Unless is says "ELF-64" or "LP64" it's a 32-bit application. COmpiling with "+DA2.0W" will generate a 64-bit application.

Regards!

...JRF...
KennethMRay
Advisor

Re: malloc() - Error No 12

Yeah, I got ya on the maxdsiz for 32 bit and maxdsiz_64bit for 64 bit apps...I just can't understand why this program at 32bit will only alloc about 889mb on this host and then when ran on the other host go up to just over 1GB? I can't see why it will do it there but not on this host as they are configured the same.

Any ideas on why that might be?

Thanks so much!
Don Morris_1
Honored Contributor

Re: malloc() - Error No 12

It's right there in your output (and if this is a default executable [no use of chatr to go EXEC_MAGIC]), I'm sorry -- but I don't believe you when you claim it goes above 1Gb for a 32-bit app. It may go over 1 billion bytes, but that's not the same thing.

Anyway -- the difference in the machines in the difference in maxssiz:

< maxssiz 134217728 134217728 Immed
---
> maxssiz 8388608 Default Immed

The default layout for 32-bit applications is 2 private quadrants and 2 shared quadrants. One private quadrant is used for the Text (yes, there's a lot of virtual address space that's unused for small programs... but there's optimizations when you have the same binary run in many places and only Read+Executable. Performance is a good thing... and that's why EXEC_MAGIC isn't the default).

The other private quadrant holds all other private objects -- that's your heap [where the malloc is going] _and_ MAP_PRIVATE mmap objects _and_ most importantly, your stack. The stack grows from low addresses to high -- so in order for maxssiz to work, the stack *must* start maxssiz (rounded down to a page) before the end of the private quadrant. You can't span the quadrant.

So a higher maxssiz means you have less space for other private data... such as your malloc() space. On one system, you have 128Mb of virtual address space reserved for stack consumption. No malloc() over 896Mb [minus 4096 bytes, but close enough] will be possible... because you hit the stack.

On the other, the stack is only 8Mb, hence you have around 1016Mb available for other private objects.

Or in short, if you want more data -- lower maxssiz.
Dennis Handly
Acclaimed Contributor

Re: malloc() - Error No 12

>JRF: Further, a 32-bit application has a data size limit of about 940MB unless it has been enabled with 'chatr' to be an EXEC_MAGIC executable

For PA you can get 3 Gb without -N by using chatr +q3p enable +q4p enable

>Compiling with "+DA2.0W" will generate a 64-bit application.

+DD64 should be used instead of the obsolete +DA2.0W form.
KennethMRay
Advisor

Re: malloc() - Error No 12

Regarding the over 1gb...i simply used that to...never mind.

I appreciate all of the education that I am getting here. My question is simply why would it be able to allocate more memory on one system than the other.

The smaller maxssiz is set on the system that is able to allocate more memory...


Thanks,
Don Morris_1
Honored Contributor
Solution

Re: malloc() - Error No 12

Exactly. maxssiz is the default size of the stack. The stack reserves virtual address space from the Private virtual address space available to the process, in the amount of the stack size (and hence maxssiz).

If you have X Gb [in this case 1] available as potential malloc space, and you always take away maxssiz -- the bigger maxssiz is, the less you have left. Hence the machine that can malloc more, does so because maxssiz is smaller (and the stack reserves less virtual address space).