source: trunk/minix/man/man1/chmem.1@ 9

Last change on this file since 9 was 9, checked in by Mattia Monga, 13 years ago

Minix 3.1.2a

File size: 1.9 KB
Line 
1.TH CHMEM 1
2.SH NAME
3chmem \- change memory allocation
4.SH SYNOPSIS
5\fBchmem\fR [\fB+\fR]\fR [\fB\-\fR] [\fB=\fR] \fIamount file\fR
6.br
7.de FL
8.TP
9\\fB\\$1\\fR
10\\$2
11..
12.de EX
13.TP 20
14\\fB\\$1\\fR
15# \\$2
16..
17.SH EXAMPLES
18.EX "chmem =50000 a.out" "Give \fIa.out\fP 50K of stack space"
19.EX "chmem \-4000 a.out" "Reduce the stack space by 4000 bytes"
20.EX "chmem +1000 file1" "Increase each stack by 1000 bytes"
21.SH DESCRIPTION
22.PP
23When a program is loaded into memory, it is allocated enough memory
24for the text and data+bss segments, plus
25an area for the stack.
26Data segment growth using
27.I malloc ,
28.I brk ,
29or
30.I sbrk
31eats up stack space from the low end.
32The amount of stack space to allocate is derived
33from a field in the executable program's file header.
34If the combined stack and data segment growth exceeds the stack space
35allocated, the program will be terminated.
36.PP
37It is therefore important to set the amount of stack space carefully.
38If too little is provided, the program may crash.
39If too much is provided, memory will be wasted, and fewer programs will be able
40to fit in memory and run simultaneously.
41\s-1MINIX 3\s-1
42does not swap, so that when memory is full, subsequent attempts to fork will
43fail.
44The compiler sets the stack space
45to the largest possible value (for the Intel CPUs, 64K \- text \- data).
46For many programs, this value is far too large.
47Nonrecursive programs that do not call
48.I brk ,
49.I sbrk ,
50or
51.I malloc ,
52and do not have any local arrays usually do not need more than 8K of stack
53space.
54.PP
55The
56.I chmem
57command changes the value of the header field that determines the stack allocation, and
58thus indirectly the total memory required to run the program.
59The = option sets the stack size
60to a specific value; the + and \- options increment and decrement the
61current value by the indicated amount.
62The old and new stack sizes are printed.
63.SH "SEE ALSO"
64.BR install (1),
65.BR brk (2).
Note: See TracBrowser for help on using the repository browser.