General
cancel
Showing results for 
Search instead for 
Did you mean: 

Get available virtual address space of process

uiqbal
Advisor

Get available virtual address space of process

All,

I would like to know how can i know the limit on the virtual address space of a 32-bit process. The breakdown for the kernel and user space addressing for a process.

If i can know about the kernel address space size i can get the size available to a process for user addressing using malloc and mmap etc.

Can somebody help me out with this? Also the api, getrlimit(RLIMIT_AS, ..) isn't working and returning RLIM_INFINITY meaning no limit is defined -- what is this?

Best regards,
RUI
1 REPLY
Don Morris_1
Honored Contributor

Re: Get available virtual address space of process

Um... what? Unless you're still talking 32-bit HP-UX (11.0 or 11.11) there's no kernel addressing in a user process. [And sorry -- I don't see a point in discussing 32-bit kernels.]

Frankly, I think the simplest thing to do would be to point you at: http://docs.hp.com/en/8681/aas_white_paper.pdf

That gives the general 32-bit breakdown and the differences between the magics for 32-bit.

For malloc -- the maximum size is _always_ the minimum of the soft rlimit for RLIMIT_DATA, the amount of swap available (pst_vminfo.psv_swapmem_max + pst_vminfo.psv_swapspc_max) and the delta between the current end of the heap (PS_DATA object -- pstat_getprocvm() iteration is how you find this) and the next object in the process [may be the PS_STACK, could be private mmap]. Obviously, this is a moving target (swap can come back, that private mmap can go away).

The nice thing about the above method -- it works regardless of Magic / Address space issues because the kernel always puts the Heap and the Stack at opposite ends of the private (data) address space on all supported releases of HP-UX.

For mmap() -- that's a loaded question. If it is file backed -- swap does not limit it at all. If is MAP_ANONYMOUS, swap will come into play. Otherwise, you have to differentiate between MAP_PRIVATE vs. MAP_SHARED (different virtual address space areas) and the address space layout of the process (MGAS vs. MPAS, type of Magic, etc.)