Find Virtual address space size for process | Unix Linux Forums | Programming

  Go Back    


Programming Post questions about C, C++, Java, SQL, and other programming languages here.

Find Virtual address space size for process

Programming


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 11-04-2008
uiqbal uiqbal is offline
Registered User
 
Join Date: May 2008
Last Activity: 18 November 2008, 1:21 PM EST
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Find Virtual address space size for process

Hi,

I am looking to work on unix systems which include (hp-ux, ibm aix, solaris and linux). I want to get the total virtual address space of a process, the used virtual memory i am able to get without any problem. I have tried using getrlimit and getrlimit64, but that gives only RLIMIT_INIFINITY or RLIMIT64_INFINITY if i use the getrlimit64.

Can you give me an idea on how much virtual addressable space is there in unix system for a user application to allocate as i need to do my memory allocations based on that?


Best regards,
uiqbal
Sponsored Links
    #2  
Old 11-04-2008
shamrock shamrock is online now Forum Advisor  
Registered User
 
Join Date: Oct 2007
Last Activity: 31 October 2014, 6:22 PM EDT
Location: USA
Posts: 1,498
Thanks: 22
Thanked 146 Times in 138 Posts
The total virtual address space of a process depends on whether the process is 32-bit or 64-bit.
While the total virtual memory on the system is the sum of physical memory plus swap.
Sponsored Links
    #3  
Old 11-04-2008
odys odys is offline
Registered User
 
Join Date: Feb 2005
Last Activity: 6 March 2011, 5:55 PM EST
Posts: 62
Thanks: 0
Thanked 1 Time in 1 Post
Hello,

My suggestions:
1. sysconf() and _SC_PHYS_PAGES, not quite what you want and may be nonportable
2. /usr/bin/free or /proc/meminfo or equivalent to cut total memory from. I think you can write separate [portable] script that gets the information on platforms you need.
    #4  
Old 11-04-2008
uiqbal uiqbal is offline
Registered User
 
Join Date: May 2008
Last Activity: 18 November 2008, 1:21 PM EST
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Hi again,

I would always be working in 32 bit environment. My question is related to virtual memory or the memory user can allocate in a process -- i.e. the virtual address space of the process in user mode. How do i know that how much is reserved for the process on all the unix(help about any one of ibm aix, hp ux, sun os and linux welcomed)??

Best regards,
uiqbal
Sponsored Links
    #5  
Old 11-05-2008
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
 
Join Date: Feb 2004
Last Activity: 31 October 2014, 2:57 PM EDT
Location: NM
Posts: 10,258
Thanks: 285
Thanked 803 Times in 747 Posts
Your assumption seems wrong to me.

First off, Shamrock showed you how to get address space there is for a process versus how much "physical" virtual space is available through hardware and disk files.

The "hardware" part is OS dependent. Your assumption is that somehow the system reserves virtual space for each process. NO. It does not. The system gives memory space via sbrk() or brk() calls to any process requesting it. brk() fails when there is no more virtual space to be had. sbrk() returns SBRK_FAILED and brk() returns -1 on failure.

If the system "set aside" memory ahead of time, then these calls would not be needed.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
PC RAM and process address space rupeshkp728 Programming 3 12-01-2011 02:53 PM
Process self-exec and virtual memory size matrixmadhan UNIX for Advanced & Expert Users 2 05-05-2010 04:34 PM
How to get address space size that a process is allowed to use Sendil Kumar Programming 2 05-05-2010 11:07 AM
how can i get The total size of the process in virtual memory om GB or MB umen UNIX for Dummies Questions & Answers 1 02-21-2007 06:43 AM
How to find the size of Process Address space. S.Vishwanath UNIX for Dummies Questions & Answers 1 07-10-2001 08:46 AM



All times are GMT -4. The time now is 06:51 PM.