Permanently set maxdata to maximum

Hi,
I've a 32-bit program running on AIX. By default the memory limit of the process is 256 MB as per the 32-bit AIX OS behavior. This can be changed using the LDR_CNTRL=maxdata environment variable. Baseed on the value that we set in terms of increments of segments the process can consume more memory when required.
During compile time also this can be set using "-bmaxdata:0x80000000" which would increase the max memory limit to 2.25GB. The question that I have is, is it OK to do do this max memory setting on my program? Are there are limitation/issues due to this?
Would appreciate if I could get the details.

        Thanks'n Regards     
        -KPRajesh

The only fair answer is "It depends" on what the application needs.

FYI: you can also use the program ldedit to change this value. Something else I would recommend is to change the default page size from 4k to 64k.

p.s. when I am back from vacation I will add links to on line documentation - unless someone else beats me to it.

1 Like

Thank you Michael for the quick reply.
In the case of my binary, the amount of memory that is consumed will increase when the load on it goes high. So I thought of setting the maximum memory. So was wondering if this idea is good. Please suggest.
Michale when you said "It depends", could you please be elaborate?

ps: I'm aware of using ldedit as well.

-KPRajesh

Mainly, it depends on how much memory you have in the system, aka partition or virtual machine. note also 0x80000000 is not the maximum (hope i am getting all the zeros right). From memory, it is now up to 13 segments you can use (increase by 12, as one is for kernel, one for code (that too can be increased by one if i recall correctly), and one for device drivers and shared library code and data.

What you lose is segments that are easily shared by programs. However, to minimize that their is an additional setting, but i do not recall that (i.e., i must refer to documentation i do not have handy).

If you do not know it already I recommend you learn to use svmon to monitor how your program is using memory, and hopefully not paging space.

In short, if you are also using shared memory for anything, and you have enough free memory for the process, there should be little to worry about.

The amount of memory available on the system varies from 256MB to 4GB. This is because customers using my program has systems with different memory sizes.

1) I have a clarification to understand the AIX mem mgmt behavior. Suppose that I do not set the LDR_CNTRL=maxdata flag in which case my program can use max. of 256MB, right? Now say my program has done malloc/calloc and reached 256MB. If my program again wants more memory using calloc/malloc, what happens? Will it get addtional memory after some memory are swapped to swap space? And if no swap space is available I guess it would cause SEGV.

2) When you said "using shared memory ..." what did you mean?

3) The additional option, is it MALLOCOPTIONS=disclaim? We've tried this but makes the process very slow. Any other option?

Thanks
-KPRajesh

about to board a plane. later.

After many hours of travel, and some sleep I have for you - this link with the basis information: https://www-01.ibm.com/support/knowledgecenter/ssw\_aix\_71/com.ibm.aix.genprogc/lrg\_prg_support.htm

Basically, what happens is that system and code remain in segments 0 and 1.
When maxdata is not equal to 0 (zero) - which is default, segment 2 is used for the stack and application .data (pre-initialized data) and .bss (aka heap for malloc calls) start in segment 3 and continue for the number of segments specified.

As you mentioned in your initial question the "official" large memory support model has a maximum MAXDATA value of 0x80000000 - so that is 2.25 G total (256MB (roughly) for the stack, and 2 GByte (8x 256 MByte) for application .data and .bss

From the discussion, I do not think you will want to use the DSA - dynamic segment allocation - option (so-called or the VERY large memory option ). However, if 2G Byte for .data and .bss is not going to be enough you may need to use that.

Back to "shared" memory - the default memory model setup uses only segments 0, 1, and 2 for the memory model - the segments there are 12 segments (numbers 3-12 and 14 are used by shmap or mmap routines). Historically, segments 13 and 15 were used by global shared libraries text and data. When you use the DSA option global shared libraries are not used - instead the shared libraries are loaded "privately" into segment 15 - both text and data. This free up segment 13 giving an application at least one additional segment.

If you are not using shmap or mmap routines then the "very large" model should work fairly easy. However, if you do use either of these routines they may impact the maximum memory available via malloc(). - keyword here: potential impact!

I hope this answers your question well enough.

Michael