Find Virtual address space size for process


 
Thread Tools Search this Thread
Top Forums Programming Find Virtual address space size for process
# 1  
Old 11-04-2008
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
# 2  
Old 11-04-2008
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.
# 3  
Old 11-04-2008
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
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
# 5  
Old 11-05-2008
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

How to decrease virtual size of a process after cleaning all containers and using malloc_trim (0)?

Hello all i have simple server running on linux redhat 6.1 it is build with c++ in the server i have huge std vector that holds pointers to cache objects those cache objects holds allot of data from the DB any way ... in some point in time there is simple API that suppose to clean the... (2 Replies)
Discussion started by: umen
2 Replies

2. Programming

PC RAM and process address space

Suppose I have 3 gb of ram and 250 gb hard disk in my pc. Now I wrote a simple C program having only one statement malloc() to allocate 4 gb of memory as 32 bit os can address 4gb address space then will the malloc succeed? If yes then how it will get extra 1 gb of memory? Does the process gets... (3 Replies)
Discussion started by: rupeshkp728
3 Replies

3. UNIX for Dummies Questions & Answers

What would the physical address be for virtual address?

Hi guys, I got one problem which I definetily no idea. What would the physical address be for virtual address? 1) 2ABC 2) 3F4B Here is the page table:see attached Thank you sos sososososso much!! (0 Replies)
Discussion started by: lemon_06
0 Replies

4. UNIX for Advanced & Expert Users

Process self-exec and virtual memory size

Hello all, To do a self-exec or self-restart of a process when it crosses the threshold memory limit, I use the value of virtual memory size field from /proc/$pid/stat file and do a self-exec. According to man 5 proc vsize %lu Virtual memory size in bytes. I just want to... (2 Replies)
Discussion started by: matrixmadhan
2 Replies

5. Programming

How to get address space size that a process is allowed to use

Hi All, From C++, I just want to find the address space size that a process is allowed to use. For ex, in 32 bit OS the allowed address space is 4GB and in 64 bit OS I guess this is 16GB or more. I jsut want to find it in my C++ project. Is there any API calls that gives me such information.... (2 Replies)
Discussion started by: Sendil Kumar
2 Replies

6. UNIX for Advanced & Expert Users

Can kernel process access user address space ?

Can kernel process access user address space ? (2 Replies)
Discussion started by: subhotech
2 Replies

7. Shell Programming and Scripting

find process size script

Hello i am working on a project here is part of script that i need a help in get process SpectroSERVER current size if it exceed 3850 MB then #pkill -TERM ArchMgr and wait to succfull shutdown message from the log file to proceed to the next step #tail -f $SPECROOT/SS/DDM/ARCHMGR.OUT... (7 Replies)
Discussion started by: mogabr
7 Replies

8. UNIX for Dummies Questions & Answers

how can i get The total size of the process in virtual memory om GB or MB

Hello all im using the ps -ef "args vsz" | some.exe but the result is in kb , is there some kind of way or flag ( didnt found in the ps man ) to convert me this data to GB or MG in human readable format ? Thanks (1 Reply)
Discussion started by: umen
1 Replies

9. Programming

How to find out the stack size occupied for a process?

Hi, In Linux how to find out what will be the stack size allocated for a process? Actually i have to fork n number of processess, and will call exec. I will be execing an executable which is already multithreaded and each thread size is defined. My doubt is how to know if the size of the... (2 Replies)
Discussion started by: rvan
2 Replies

10. UNIX for Dummies Questions & Answers

How to find the size of Process Address space.

Hello, Please help me to know, How to find out the how much amount of process addres space is required/is used for/by a process. Tnx & Regards Vishwa. (1 Reply)
Discussion started by: S.Vishwanath
1 Replies
Login or Register to Ask a Question