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.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
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
2. Programming
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
3. UNIX for Dummies Questions & Answers
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
4. Shell Programming and Scripting
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
5. UNIX for Advanced & Expert Users
Can kernel process access user address space ? (2 Replies)
Discussion started by: subhotech
2 Replies
6. Programming
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
7. UNIX for Advanced & Expert Users
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
8. UNIX for Dummies Questions & Answers
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
9. Programming
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
10. Programming
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
LEARN ABOUT REDHAT
mremap
MREMAP(2) Linux Programmer's Manual MREMAP(2)
NAME
mremap - re-map a virtual memory address
SYNOPSIS
#include <unistd.h>
#include <sys/mman.h>
void * mremap(void *old_address, size_t old_size , size_t new_size, unsigned long flags);
DESCRIPTION
mremap expands (or shrinks) an existing memory mapping, potentially moving it at the same time (controlled by the flags argument and the
available virtual address space).
old_address is the old address of the virtual memory block that you want to expand (or shrink). Note that old_address has to be page
aligned. old_size is the old size of the virtual memory block. new_size is the requested size of the virtual memory block after the
resize.
The flags argument is a bitmap of flags.
In Linux the memory is divided into pages. A user process has (one or) several linear virtual memory segments. Each virtual memory seg-
ment has one or more mappings to real memory pages (in the page table). Each virtual memory segment has its own protection (access
rights), which may cause a segmentation violation if the memory is accessed incorrectly (e.g., writing to a read-only segment). Accessing
virtual memory outside of the segments will also cause a segmentation violation.
mremap uses the Linux page table scheme. mremap changes the mapping between virtual addresses and memory pages. This can be used to
implement a very efficient realloc.
FLAGS
MREMAP_MAYMOVE
indicates if the operation should fail, or change the virtual address if the resize cannot be done at the current virtual address.
RETURN VALUE
On success mremap returns a pointer to the new virtual memory area. On error, -1 is returned, and errno is set appropriately.
ERRORS
EINVAL An invalid argument was given. Most likely old_address was not page aligned.
EFAULT "Segmentation fault." Some address in the range old_address to old_address+old_size is an invalid virtual memory address for this
process. You can also get EFAULT even if there exist mappings that cover the whole address space requested, but those mappings are
of different types.
EAGAIN The memory segment is locked and cannot be re-mapped.
ENOMEM The memory area cannot be expanded at the current virtual address, and the MREMAP_MAYMOVE flag is not set in flags. Or, there is
not enough (virtual) memory available.
NOTES
With current glibc includes, in order to get the definition of MREMAP_MAYMOVE, you need to define _GNU_SOURCE before including
<sys/mman.h>.
CONFORMING TO
This call is Linux-specific, and should not be used in programs intended to be portable. 4.2BSD had a (never actually implemented)
mremap(2) call with completely different semantics.
SEE ALSO
getpagesize(2), realloc(3), malloc(3), brk(2), sbrk(2), mmap(2)
Your favorite OS text book for more information on paged memory. (Modern Operating Systems by Andrew S. Tannenbaum, Inside Linux by Ran-
dolf Bentson, The Design of the UNIX Operating System by Maurice J. Bach.)
Linux 1.3.87 1996-04-12 MREMAP(2)